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.
This commit is contained in:
rlaphoenix 2023-02-25 11:47:39 +00:00
parent 8d626822cb
commit f1864ad63c
1 changed files with 13 additions and 2 deletions

View File

@ -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: