Skip to main content

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

import logging
import np_logging

np_logging.setup() runs automatically on import to add handlers and loggers from a default config, then the logging module can be used as normal.

ZooKeeper configs can be fetched via their path:

test_config: dict = np_logging.fetch_zk_config(
    '/projects/np_logging_test/defaults/logging'
)

Once a logging config dict has been modified as necessary...

test_config['handlers']['email_handler']['toaddrs'] = username@alleninstitute.org

re-run the logging setup with the new config dict:

np_logging.setup(
    config: dict = test_config,
    project_name = 'test',
)
  • project_name should be supplied to use the web logger - if unspecified, the name of the current working directory is used
  • the web log can be viewed at http://eng-mindscope:8080

The default config provides the loggers web and email, in addition to the default root which includes file handlers for info and debug logging levels, plus console logging:

logging.getLogger('web').info('test message')
logging.getLogger('email').info('test message')
logging.debug('test message to files and console')

Other input arguments to np_logging.setup():

  • log_at_exit (default True)

    • If True, a message is logged when the program terminates, reporting total elapsed time.
  • email_at_exit (default False)

    • If True, an email is sent when the program terminates, reporting the elapsed time and cause of termination. If an exception was raised, the traceback is included.

    • If logging.error, the email is only sent if the program terminates via an exception.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

np_logging-0.1.8.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

np_logging-0.1.8-py3-none-any.whl (5.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page