You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
685 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"""工具函数:日志处理、异常捕获等"""
import os
from loguru import logger
import datetime
def init_logger():
"""初始化日志配置"""
log_dir = "logs"
if not os.path.exists(log_dir):
os.makedirs(log_dir)
# 日志文件名(按日期)
log_file = f"{log_dir}/llm_analysis_{datetime.date.today()}.log"
# 配置日志:控制台+文件输出保留7天日志
logger.add(
log_file,
format="{time:YYYY-MM-DD HH:mm:ss} | {level} | {message}",
rotation="00:00",
retention="7 days",
level="INFO"
)
return logger
# 初始化日志
logger = init_logger()