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:
commit
81170eee00
1 changed files with 13 additions and 4 deletions
|
|
@ -9,12 +9,12 @@ from loguru import logger
|
|||
from rich.console import Console
|
||||
from rich.markup import escape
|
||||
from rich.progress import (
|
||||
Progress,
|
||||
TextColumn,
|
||||
BarColumn,
|
||||
TimeRemainingColumn,
|
||||
TaskProgressColumn,
|
||||
MofNCompleteColumn,
|
||||
Progress,
|
||||
TaskProgressColumn,
|
||||
TextColumn,
|
||||
TimeRemainingColumn,
|
||||
)
|
||||
|
||||
from common.utils import unwrap
|
||||
|
|
@ -115,3 +115,12 @@ def setup_logger():
|
|||
format=_log_formatter,
|
||||
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
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue