mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
unify logging with rich
This commit is contained in:
parent
30bb877fcc
commit
429909344d
22
app/logging.py
Normal file
22
app/logging.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
from rich.console import Console
|
||||||
|
from rich.logging import RichHandler
|
||||||
|
|
||||||
|
|
||||||
|
from app.utils import SingletonMeta
|
||||||
|
|
||||||
|
|
||||||
|
class AppLogger(metaclass=SingletonMeta):
|
||||||
|
_logger = None
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self._logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
def get_logger(self):
|
||||||
|
return self._logger
|
||||||
|
|
||||||
|
|
||||||
|
class RichConsoleHandler(RichHandler):
|
||||||
|
def __init__(self, width=200, style=None, **kwargs):
|
||||||
|
super().__init__(console=Console(color_system="256", width=width, style=style), **kwargs)
|
Loading…
x
Reference in New Issue
Block a user