mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
18 lines
552 B
Python
18 lines
552 B
Python
import logging
|
|
from functools import lru_cache
|
|
|
|
from rich.console import Console
|
|
from rich.logging import RichHandler
|
|
|
|
console = Console(color_system="256", width=200, style="blue")
|
|
|
|
|
|
@lru_cache()
|
|
def get_logger(module_name):
|
|
logger = logging.getLogger(module_name)
|
|
handler = RichHandler(rich_tracebacks=True, console=console, tracebacks_show_locals=True)
|
|
handler.setFormatter(logging.Formatter("[ %(threadName)s:%(funcName)s:%(lineno)d ] - %(message)s"))
|
|
logger.addHandler(handler)
|
|
logger.setLevel(logging.DEBUG)
|
|
return logger
|