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.0.tar.gz
.
File metadata
- Download URL: logging-interceptor-0.1.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.15 CPython/3.10.4 Linux/5.15.0-43-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89907339ca77e47845f8c53d00ccdc97be0008906c059b5d16dc74213c4dd386 |
|
MD5 | af284c2e7f4eae4a4d14448fcf24e662 |
|
BLAKE2b-256 | 80a33a8af279c7d412354c081f34eff8616866a335b4f5f80154f8fcc8539e28 |
File details
Details for the file logging_interceptor-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: logging_interceptor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.15 CPython/3.10.4 Linux/5.15.0-43-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec7dbdedc81eee87205b652a5331d68643d381cdd900249229386e59ee5d6f52 |
|
MD5 | cfe58428257f85309653ee69ee99b7b9 |
|
BLAKE2b-256 | b7a69d7d0ce245db72b738503efed853d99f2daf8dae7bf0c0b703e676f58c0b |