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.1.dev0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logging_interceptor-0.1.1.dev0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file logging-interceptor-0.1.1.dev0.tar.gz.

File metadata

  • Download URL: logging-interceptor-0.1.1.dev0.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

Hashes for logging-interceptor-0.1.1.dev0.tar.gz
Algorithm Hash digest
SHA256 ef04f390fd2a2f6cada6c807fed8112ab389737ccaf2af2f7fe23e4b366a3173
MD5 5a48896ecf8e4c497ac8072f3e5f1241
BLAKE2b-256 74b929fa428143275adae48025e57698ace398edde1ab123608736fc2c4aff2d

See more details on using hashes here.

File details

Details for the file logging_interceptor-0.1.1.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for logging_interceptor-0.1.1.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ccaf3aaf14768520259fda71cd2d3e02b7aa129719f9297a2e0455f96f53b42
MD5 4b344bd2d73ead58da562efa4488d4e5
BLAKE2b-256 c28da80100d13ff4dbcfb5fdfb7d199461695d52bf10880128b24457948e9673

See more details on using hashes here.

Supported by

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