Skip to content

MatthewScholefield/loguru-logging-intercept

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Loguru Logging Intercept

PyPI - Version PyPI - Downloads

Code to integrate Loguru with Python's standard logging module

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 a function that sets 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:

import logging
from loguru_logging_intercept import setup_loguru_logging_intercept


def main():
    setup_loguru_logging_intercept(
        level=logging.DEBUG,
        modules=("foo", "foo.bar", "foo.baz")
    )
    # Can now call functions from foo that use getLogger(__name__)

...

Installation

Install via pip:

pip3 install loguru-logging-intercept

About

Code to integrate Loguru with Python's standard logging module

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages