Skip to main content

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.

Metadata

Release files for np-logging 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for np-logging 0.5.2
File Size Uploaded Provenance
np_logging-0.5.2.tar.gz 10.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for np-logging 0.5.2
File Interpreter ABI Platform
np_logging-0.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 21.1 kB

Release files / np_logging-0.5.2.tar.gz

Download URL np_logging-0.5.2.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
88bfd5483a790c53bcf6edfd6c5deaa6432773eef02367ea4dfd92412765c322
BLAKE2b-256 checksum
How to use checksums
90db366b08dd1064d1969c851534d46fb39f6a06c6d81b892f40d1eb6c3b93ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.11.5 Windows/10

Release files / np_logging-0.5.2-py3-none-any.whl

Download URL np_logging-0.5.2-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
53d4df95dc4bdb6bab3afc22740c50aa5756d71fbb23033d8b4d6199aa7adf4b
BLAKE2b-256 checksum
How to use checksums
917b66ecb683f5a5477d14728b622c47d6a0f86ff32d7981f4dd072ca29d8ea2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.11.5 Windows/10

Security for np-logging 0.5.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.5.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page