From 429909344d58bb856fd949bab9d92384e978dc25 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Mon, 10 Apr 2023 21:42:00 +0200 Subject: [PATCH] unify logging with rich --- app/logging.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 app/logging.py diff --git a/app/logging.py b/app/logging.py new file mode 100644 index 0000000..9815e7c --- /dev/null +++ b/app/logging.py @@ -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)