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 np_logging
logger = np_logging.getLogger(__name__)
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.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d7886fe15f0c2eab7973883c41144322b3bab4a4b33702607d838bbce7d9fad |
|
MD5 | 44d54d684c378d5b37e5c5781030fd8f |
|
BLAKE2b-256 | 02e1a6bfca67cbb31fb306c4b3c536911c965d265b9556a4b493e7d0571df8ce |