Pre-configured file, web, and email logging for Mindscope neuropixels projects, repackaging code from AIBS mpeconfig.
Project description
np_logging
For use on internal Allen Institute network
Quick start
Follow the conventions for using the logging
module in the standard library:
- in a script or main module,
np_logging
adds console & file handlers and exit messages to the root logger:
import np_logging
logger = np_logging.getLogger()
- or, in a package or project with multiple modules, all logged messages are propagated to the root logger:
import np_logging
logger = np_logging.getLogger(__name__) # logger.level = logging.NOTSET = 0
- then log messages as usual:
logger.info('test message')
logger.warning('test message')
No further setup is required, and importing logging
from the standard library isn't necessary.
To send a message to the Mindscope log-server, use np_logging.web()
and supply a project name, which will
appear in the
channel
field on the server:
project_name = 'spike_sorting'
np_logging.web(project_name).info('test message')
- the web log can be viewed at http://eng-mindscope:8080
For customization, use np_logging.setup()
to supply a logging config dict that specifies
loggers and their handlers & formatters, and np_logging will add extra functionality such as exit messages/emails.
-
logging configs should be specified according to the python logging library dict schema
-
logging configs on the
eng-mindscope
ZooKeeper server can also be used directly to setup logging by supplying their path tonp_logging.setup()
:
np_logging.setup(
'/projects/np_workflows/defaults/logging'
)
See np_config for further info on using ZooKeeper for configs.
Other input arguments to np_logging.setup()
:
-
project_name
(default: current working directory name)- sets the
channel
displayed on the log server
- sets the
-
email_address
(default:None
)- if one or more addresses are supplied, an email is sent at program exit reporting the elapsed time and cause of termination. If an exception was raised, the traceback is included.
-
log_at_exit
(default:True
)- If
True
, a message is logged when the program terminates, reporting total elapsed time.
- If
-
email_at_exit
(default:False
, orTrue
ifemail_address
is notNone
)-
If
True
, an email is sent when the program terminates. -
If
logging.ERROR
, the email is only sent if the program terminates via an exception.
-
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file np_logging-0.5.1.tar.gz
.
File metadata
- Download URL: np_logging-0.5.1.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.11.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e258eef7a9214246d1a0b0109f0d09f830c002777b83036009ac568a2a0b01a |
|
MD5 | a274ec9e8131ae46e9c1698ac35ad39e |
|
BLAKE2b-256 | b25ea21974a9ef2026884e679eda11222093ae5daa19b4a614a54f4a93800888 |
File details
Details for the file np_logging-0.5.1-py3-none-any.whl
.
File metadata
- Download URL: np_logging-0.5.1-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.11.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b48435c17ba7182253c43666dbcab88472e14fabbd5089a248a08509572e1764 |
|
MD5 | 174c7fd92b30ea907292a4c3a5a50d7a |
|
BLAKE2b-256 | 917b9ba634f79c1267913f266444978f0672efdc8b9cb2b7c4fcd4358086875f |