mirror of
https://github.com/Benexl/FastAnime.git
synced 2026-01-11 04:33:35 -08:00
feat: update config logic with new philosophy
This commit is contained in:
30
fastanime/cli/utils/logging.py
Normal file
30
fastanime/cli/utils/logging.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import logging
|
||||
from rich.traceback import install as rich_install
|
||||
from ..constants import LOG_FILE_PATH
|
||||
|
||||
|
||||
def setup_logging(log: bool, log_file: bool, rich_traceback: bool) -> None:
|
||||
"""Configures the application's logging based on CLI flags."""
|
||||
if rich_traceback:
|
||||
rich_install(show_locals=True)
|
||||
|
||||
if log:
|
||||
from rich.logging import RichHandler
|
||||
|
||||
logging.basicConfig(
|
||||
level="DEBUG",
|
||||
format="%(message)s",
|
||||
datefmt="[%X]",
|
||||
handlers=[RichHandler()],
|
||||
)
|
||||
logging.getLogger(__name__).info("Rich logging initialized.")
|
||||
elif log_file:
|
||||
logging.basicConfig(
|
||||
level="DEBUG",
|
||||
filename=LOG_FILE_PATH,
|
||||
format="%(asctime)s %(levelname)s: %(message)s",
|
||||
datefmt="[%d/%m/%Y@%H:%M:%S]",
|
||||
filemode="w",
|
||||
)
|
||||
else:
|
||||
logging.basicConfig(level="CRITICAL")
|
||||
Reference in New Issue
Block a user