Pre-configured file, web, and email logging for Mindscope neuropixels projects, repackaging code from AIBS mpeconfig.
Project description
For use on internal Allen Institute network
Quick start:
import logging
import np_logging
np_logging.setup()
np_logging.setup()
with no arguments uses a default config, providing the loggers web
and email
, in addition to the default
root
which includes file handlers for logging.INFO
and logging.DEBUG
levels, plus
console logging.
The built-in python logging
module can then be used as normal.
Usage example:
logging.getLogger('web').info('test: web server')
logging.getLogger('email').info('test: email logger')
logging.debug('test: root logger')
-
user configs should be specified according to the python logging library dict schema
-
the default config is fetched from the ZooKeeper server
eng-mindscope:2181
-
configs can be added via ZooNavigator webview: http://eng-mindscope:8081
-
or more conveniently, via an extension for VSCode such as gaoliang.visual-zookeeper
ZooKeeper configs or config files can be used by supplying their path to setup()
:
np_logging.setup(
'/projects/np_logging_test/defaults/logging'
)
Other input arguments to np_logging.setup()
:
-
project_name
(default current working directory name)- sets the
channel
value for the web logger - the web log can be viewed at http://eng-mindscope:8080
- sets the
-
email_address
(defaultNone
)- 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
(defaultTrue
)- If
True
, a message is logged when the program terminates, reporting total elapsed time.
- If
-
email_at_exit
(defaultFalse
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
Hashes for np_logging-0.2.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a4c850c892a314331e8cde1e12811dbfe559e46895926f797f8cc1d526d8614 |
|
MD5 | 70c8990bd0a74e678453804049ed6fc4 |
|
BLAKE2b-256 | cc643e4ec2d97b0ebc6a6aa54d4082ded9a2e43e56e367bd9b22431e407bf1fd |