From f1864ad63cfb3242bb38fea1a2d7dce5e18067ab Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Sat, 25 Feb 2023 11:47:39 +0000 Subject: [PATCH] Replace logging handler with ComfyRichHandler This changes all logs via logging to be printed to the rich console instead. Specifically, using my custom ComfyRichHandler making the logs padded horizontally. In this change the time is no longer printed. The log level is still printed but it's now the full log name in bold. --- devine/core/__main__.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/devine/core/__main__.py b/devine/core/__main__.py index adeb36f..0805b6b 100644 --- a/devine/core/__main__.py +++ b/devine/core/__main__.py @@ -10,7 +10,7 @@ from urllib3.exceptions import InsecureRequestWarning from devine.core import __version__ from devine.core.commands import Commands from devine.core.config import config -from devine.core.console import console +from devine.core.console import ComfyRichHandler, console from devine.core.constants import context_settings from devine.core.utilities import rotate_log_file @@ -24,7 +24,18 @@ LOGGING_PATH = None help="Log path (or filename). Path can contain the following f-string args: {name} {time}.") def main(version: bool, debug: bool, log_path: Path) -> None: """Devine—Open-Source Movie, TV, and Music Downloading Solution.""" - logging.basicConfig(level=logging.DEBUG if debug else logging.INFO) + logging.basicConfig( + level=logging.DEBUG if debug else logging.INFO, + format="%(message)s", + handlers=[ComfyRichHandler( + show_time=False, + show_path=debug, + console=console, + rich_tracebacks=True, + tracebacks_suppress=[click], + log_renderer=console._log_render # noqa + )] + ) log = logging.getLogger() if log_path: