Metadata-Version: 2.4
Name: logging-loguru
Version: 0.4.2
Summary: Tiny script for integrating the Python's standard Logging output to the colorful logs by the Loguru library
Project-URL: Source, https://github.com/ablaternae/py-logging-loguru
Author-email: "d;)" <py-logging-loguru@github.com>
License-Expression: GLWTPL
Keywords: intercept,logging,logging handler,loguru
Classifier: Development Status :: 4 - Beta
Classifier: License :: Freeware
Classifier: License :: OSI Approved :: The Unlicense (Unlicense)
Classifier: License :: OSI Approved :: Universal Permissive License (UPL)
Classifier: License :: Public Domain
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Requires-Python: >=3.8
Requires-Dist: loguru
Description-Content-Type: text/markdown

# logging-loguru

![Lines of code](https://img.shields.io/tokei/lines/github/ablaternae/py-logging-loguru)
[![Downloads](https://img.shields.io/pypi/dm/logging-loguru)](https://pypi.org/project/logging-loguru)
[![Statistic](https://pepy.tech/badge/logging-loguru/week)](https://pepy.tech/project/logging-loguru)
[![License](https://img.shields.io/github/license/ablaternae/py-logging-loguru)](https://github.com/ablaternae/py-logging-loguru/blob/trunk/LICENSE.md)
[![Code style: black](https://img.shields.io/badge/code%20style-black-ccc.svg)](https://github.com/psf/black)

===

Tiny script for integrating the Python's standard Logging output to the colorful logs by the Loguru library.
RLY 3kb: 1 file, 1 class, 1 function


### API
```python
class InterceptHandler(logging.Handler):
    def __init__(self, logger=loguru.logger)

    def emit(self, record: logging.LogRecord) -> None

def adapt(logger=loguru.logger, log=logging, level=0)
```

### usage

#### default behavior
```python
# file.py begins

import logging
import loguru
import logging_loguru

logging_loguru.adapt()

import ...
...
```
catches all `logging.Logger` log's messages and pipes them all to default `loguru.logger` handler

#### choose Logger
```python
log = logging.getLogger("example") # ex: "flask", "WSGI", "peewee" etc, see docs

logging_loguru.adapt(log=log)
```
catches _example_'s logger messages and pipes them to default `loguru.logger` handler

#### tune handler
```python
from loguru import logger as file_logger

LOG_FORMAT = "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <level>{level: <8}</level> | <cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>"

file_logger.add(
    "example.dev-{time}.log",
    colorize=False,
    compression="gz",
    format=LOG_FORMAT,
    level="DEBUG",
    retention="10 days",
    rotation="4 hours",
    enqueue=True,
)

log = logging.getLogger("example")

logging_loguru.adapt(logger=file_logger, log=log, level="INFO")
```

That's all

===
ps: yeah, script is very similar to https://github.com/MatthewScholefield/loguru-logging-intercept/, but how could it have been written differently?
