Intercept Python's standard logging and re-route the messages.
Project description
Python Logging Interceptor
Capture Python's stdlib logging
messages and route them to other logging frameworks.
(Modified and packaged for PyPI from Matthew Scholefield's loguru-logging-intercept.)
Currently supported targets:
Loguru is a great alternative logging library for Python. However, if you use
(potentially external) code that already integrates with Python's default logger, you'll
get a combination of the two logging styles. This code provides code for setting up an
intercept handler to route calls to Python's default logging
module to Loguru.
Usage
Before calls that use Python's default logging
module, call the provided
setup_loguru_interceptor()
as shown below:
from logging_interceptor import setup_loguru_interceptor
setup_loguru_interceptor(modules=("foo", "foo.bar", "foo.baz"))
# now call functions from `foo` that use getLogger(__name__)
Installation
Install via pip
:
pip3 install logging-interceptor
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file logging_interceptor-0.1.2.tar.gz
.
File metadata
- Download URL: logging_interceptor-0.1.2.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.4 Linux/5.15.0-74-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2186a8418ae84d922e2a57e0bb48bfd2f9737e897f784dbb7eab8808fbe0a85 |
|
MD5 | 77ff327e4479d98a6e0a7766f2b97b18 |
|
BLAKE2b-256 | f581493ae002928054cb075d0e16aede958b726a58e7f5c7f4144e03583a533f |
File details
Details for the file logging_interceptor-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: logging_interceptor-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.4 Linux/5.15.0-74-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd1e1cf9e81f457427bab08f0816e1cb06e5a427667006c7aa7a0b15f11afa24 |
|
MD5 | 79faac62231a2c09ce05fbc3c617a9c1 |
|
BLAKE2b-256 | 2f592aca8986184705bcb689a7c93d7985c499ccddb7973d31e046d601111916 |