magic_logger
| Coverage | Release |
|---|---|
This very simple module does its best to help you use Python's logging correctly, by making sure you always
invoke the right Logger for a module. No more boilerplace logger.getLogger(__name__)! All this
without any external dependencies - this is just a tiny wrapper for logging.
Getting started
To install:
pip install magic_logger==1.0.0
Overview
Import logger from magic_logger and just call any methods you'd normally call on a logging.Logger instance:
# Let's assume we are in `mypackage.mymodule`
from magic_logger import logger
logger.info("Someting very informative") # equivalent to logging.getLogger(__name__).info(...)
magic_logger.logger also acts like a proxy for other commonly used functions in logging.config:
logger.dict_config(...) # dispatches to logging.config.dictConfig
logger.file_config(...) # dispatches to logging.config.file_config
logger.listen(...) # dispatches to logging.config.listen
logger.stop_listening(...) # dispatches to logging.config.stopListening
What about the other stuff in logging
For anything else, just use logging directly. magic_logger just proxies calls over anyway so you can use logging as usual.
How does it work?
When you ask for an attribute of magic_logger.logger (other than the configuration ones listed above),
it looks at the stack and determines the module from where the call originates. It then returns the attribute
of the same name of the correct logger for that module, using logging.getLogger. As simple as that!
What if I call a module using python -m and log something from it, will that use the logger for __main__?
No, it will simply look at the module's __spec__ for the name. Unless you run an interactive session and log straight from it,
you won't ever use the logger for __main__!
Metadata
Release files for magic-logger 1.0.2
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 |
|---|---|---|---|---|
| magic_logger-1.0.2.tar.gz | 3.2 kB | Without provenance | Details for magic_logger-1.0.2.tar.gz |
Release files / magic_logger-1.0.2.tar.gz
| Download URL | magic_logger-1.0.2.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92feedb1e0b1f1270725548813f4ac6b4bd3156d1ca8732a86b9b6048ac5142d
|
|
BLAKE2b-256 checksum How to use checksums |
887a3502c67466a255fddb7f417a6c90fea720e69a8c5a8cba57b1ac09094f1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.2
|
Security for magic-logger 1.0.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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.