1
This commit is contained in:
2024-11-30 21:04:03 +08:00
parent fd6006b186
commit 4142bd9423
6 changed files with 70 additions and 10 deletions

View File

@@ -1,8 +1,14 @@
import os
# configs/log_config.py
from loguru import logger
import os
# 确保 ../logs 目录存在,如果不存在则创建
os.makedirs("../logs", exist_ok=True)
def setup_logging():
# 确保日志目录存在
log_dir = "../logs"
os.makedirs(log_dir, exist_ok=True)
# 配置日志,记录到 ../logs 目录下
logger.add("../logs/chengdu_mj_engine.log", rotation="10 MB", level="DEBUG", format="{time} {level} {message}")
# 清除所有现有日志处理器,防止重复配置
logger.remove()
# 配置日志,记录到 ../logs 目录下
logger.add(os.path.join(log_dir, "chengdu_mj_engine.log"), rotation="10 MB", level="DEBUG", format="{time} {level} {message}")