This module is a thin wrapper around Structlog that sets and provides defaults for sending logs to one or more logging destinations with individual formatting per destination.
The API consists of a single function: create_logger().
- Args:
logging_config (dict): Input to logging.config.dictConfig
level(logging.loglevel): Overrides logging level for all loggers (not handlers!)
- Returns:
log: structlog Logger object
It can be invoked as follows:
logging_config = …
log = multistructlog.create_logger(config, level=logging.INFO)
log.info(‘Entered function’, foo=’bar’)
To create a logging_config dictionary, see these docs:
There are no required arguments to create_logger() - any missing parts of the config will be filled in with defaults that print structured logs to the console.
If you don’t specify a formatters section in your config, three will be created which can be used in handlers:
json: renders one JSON dictionary per message
structured: prints structured logs with the structlog.dev.ConsoleRenderer
structured-color: same as structured but with forced color output
If you don’t specify a handlers section, a handler will be added that logs to console with logging.StreamHandler with format structured at level DEBUG.
If you don’t specify a loggers section, a default logger (empty string) will be created with all items in handlers added to it, with a level of NOTSET (every level printed).
When setting log level, the higher of logging_config['loggers'][*]['level'] and logging_config['handlers'][*]['level'] is used. The level parameter overrides the loggers value of level, not the handlers level.
If the handler’s level is set to DEBUG but the logger’s level is set to ERROR, the handler will be overridden and only log ERROR level messages.
Multistructlog also adds a TRACE log level (integer level 5) that is below “DEBUG” to both standard library Logger and Structlog BoundLogger.
- List of standard logging levels:
https://docs.python.org/2.7/library/logging.html#logging-levels
Changelog
1.x versions
legacy
2.0.0
Substantial refactor/rewrite
Cache logger objects
Add trace levels
2.1.0
Force color on when using structured-color formatter
Print timestamp and loglevel by default
Fix issues with reinitialziaton of logger
Metadata
Release files for multistructlog 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| multistructlog-2.1.0.tar.gz | 4.7 kB | Without provenance | Details for multistructlog-2.1.0.tar.gz |
Release files / multistructlog-2.1.0.tar.gz
| Download URL | multistructlog-2.1.0.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e16ca424efcb90bea1c9189f0225dc2985425f5664090e22107472b31fb80b62
|
|
BLAKE2b-256 checksum How to use checksums |
1f8ee9c82d711a9fee1817e5fdf11e582795886f6e14827bf231683d4f129313
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15
|
Security for multistructlog 2.1.0
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.