diff --git a/common/logging.py b/common/logging.py index 50bc3f2..7122a46 100644 --- a/common/logging.py +++ b/common/logging.py @@ -13,8 +13,10 @@ Levels used in this project: ERROR - raised exceptions (caller will see the traceback) """ import sys - +from pathlib import Path from loguru import logger +Path("data/logs/debug").mkdir(parents=True, exist_ok=True) +Path("data/logs/info").mkdir(parents=True, exist_ok=True) logger.remove() logger.add( @@ -26,4 +28,24 @@ logger.add( "{name}:{function}:{line} - " "{message}" ), + enqueue=True, + colorize=True, ) + +logger.add( + "data/logs/debug/{time:YYYY-MM-DD}.log", + level="DEBUG", + enqueue=True, + retention="30 days", + compression="gz", + colorize=True, +) + +logger.add( + "data/logs/info/{time:YYYY-MM-DD}.log", + level="INFO", + enqueue=True, + retention="30 days", + compression="gz", + encoding="utf-8", +) \ No newline at end of file