Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logging_interceptor-0.1.2.tar.gz (3.0 kB view hashes)

Uploaded Source

Built Distribution

logging_interceptor-0.1.2-py3-none-any.whl (3.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page