mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
add rich logger
This commit is contained in:
parent
72ef1bebb9
commit
71588752e1
17
the_app/utils.py
Normal file
17
the_app/utils.py
Normal file
@ -0,0 +1,17 @@
|
||||
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
|
Loading…
x
Reference in New Issue
Block a user