Skip to main content

Capture Python's standard logging messages and route them to Loguru.

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'sloguru-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_logging_intercept() 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 loguru-logging-intercept

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

Uploaded Source

Built Distribution

logging_interceptor-0.1.0.dev0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: logging-interceptor-0.1.0.dev0.tar.gz
  • Upload date:
  • Size: 3.2 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.0.dev0.tar.gz
Algorithm Hash digest
SHA256 271efb86764901da6ee7e5038546ce599f3f18f71ac39d3a1093540d8675b775
MD5 54d629ca3afb4372784c7cd3c38f6db8
BLAKE2b-256 6c71d0a40b97b8c5542d2526a3da072671e2adea61e7ce8852be309403f8231e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for logging_interceptor-0.1.0.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac4abf1fc7894f3892dc132e08ad47241c66b440deaf6adc153cf5d356f79fbc
MD5 6965f25201ac8ba3cbcf7c1d34d99b30
BLAKE2b-256 6dd6575d69b7bf7153135ffa55e84eb4bbed578cde3e3739d124421b0db8918b

See more details on using hashes here.

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