Skip to main content

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')

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 to np_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
  • 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.
  • email_at_exit (default: False, or True if email_address is not None)

    • 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


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.5.2.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

np_logging-0.5.2-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file np_logging-0.5.2.tar.gz.

File metadata

  • Download URL: np_logging-0.5.2.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.5 Windows/10

File hashes

Hashes for np_logging-0.5.2.tar.gz
Algorithm Hash digest
SHA256 88bfd5483a790c53bcf6edfd6c5deaa6432773eef02367ea4dfd92412765c322
MD5 75e73900720738f25c4ea9abbfffc6b0
BLAKE2b-256 90db366b08dd1064d1969c851534d46fb39f6a06c6d81b892f40d1eb6c3b93ac

See more details on using hashes here.

File details

Details for the file np_logging-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: np_logging-0.5.2-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.5 Windows/10

File hashes

Hashes for np_logging-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 53d4df95dc4bdb6bab3afc22740c50aa5756d71fbb23033d8b4d6199aa7adf4b
MD5 505dfd9b6dd8fe61b4e442fc1f004cf8
BLAKE2b-256 917b66ecb683f5a5477d14728b622c47d6a0f86ff32d7981f4dd072ca29d8ea2

See more details on using hashes here.

Supported by

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