Merge pull request #312 from davidallada/add-file-based-logging

Add file based logging in addition to the normal console logs
This commit is contained in:
Brian 2025-05-17 01:24:19 -04:00 committed by GitHub
commit 81170eee00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,12 +9,12 @@ from loguru import logger
from rich.console import Console from rich.console import Console
from rich.markup import escape from rich.markup import escape
from rich.progress import ( from rich.progress import (
Progress,
TextColumn,
BarColumn, BarColumn,
TimeRemainingColumn,
TaskProgressColumn,
MofNCompleteColumn, MofNCompleteColumn,
Progress,
TaskProgressColumn,
TextColumn,
TimeRemainingColumn,
) )
from common.utils import unwrap from common.utils import unwrap
@ -115,3 +115,12 @@ def setup_logger():
format=_log_formatter, format=_log_formatter,
colorize=True, colorize=True,
) )
# Add file logging
logger.add(
"logs/{time}.log",
level=LOG_LEVEL,
format="{time:YYYY-MM-DD HH:mm:ss.SSS} | {level: <8} | {message}",
rotation="20 MB", # Rotate file when it reaches 20MB
retention="1 week", # Keep logs for 1 week
compression="zip", # Compress rotated log
)