Skip to content

Commit 4299093

Browse files
committed
unify logging with rich
1 parent 30bb877 commit 4299093

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

app/logging.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import logging
2+
3+
from rich.console import Console
4+
from rich.logging import RichHandler
5+
6+
7+
from app.utils import SingletonMeta
8+
9+
10+
class AppLogger(metaclass=SingletonMeta):
11+
_logger = None
12+
13+
def __init__(self):
14+
self._logger = logging.getLogger(__name__)
15+
16+
def get_logger(self):
17+
return self._logger
18+
19+
20+
class RichConsoleHandler(RichHandler):
21+
def __init__(self, width=200, style=None, **kwargs):
22+
super().__init__(console=Console(color_system="256", width=width, style=style), **kwargs)

0 commit comments

Comments
 (0)