loguru

GitHub - Delgan/loguru: Python logging made (stupidly) simple

Loguru is a library which aims to bring enjoyable logging in Python. It is intended to make Python logging less painful by adding a bunch of useful functionalities that solve caveats of the standard loggers.

Tutorial

See: A Complete Guide to Logging in Python with Loguru

loguru vs. Built-in logging

See

Switch from standard logging to loguru:

Issues and Solutions

Apply default level color in custom format

Use the special tag <level> in custom format.

The special tag <level> (abbreviated with <lvl>) is transformed according to the configured color of the logged message level.

Reference

Integrate rich.logging.RichHandler

Use configure() method of loguru.logger.

Example:

from rich.logging import RichHandler
from loguru import logger

rich_handler = RichHandler()

logger.configure(
    handlers=[
        {"sink": rich_handler, "format": "{message}"},
    ],
)

Reference