'commit'
This commit is contained in:
@@ -4,10 +4,9 @@ import logging
|
||||
from raganything import RAGAnything, RAGAnythingConfig
|
||||
from lightrag.llm.openai import openai_complete_if_cache, openai_embed
|
||||
from lightrag.utils import EmbeddingFunc
|
||||
|
||||
from logging.handlers import RotatingFileHandler# 导入RotatingFileHandler用于日志轮转
|
||||
import Config.Config
|
||||
|
||||
# 控制日志输出
|
||||
# 设置根日志记录器的级别为INFO,这样所有子记录器的日志都会被捕获
|
||||
root_logger = logging.getLogger()
|
||||
root_logger.setLevel(logging.INFO)
|
||||
@@ -18,13 +17,25 @@ if not root_logger.handlers:
|
||||
handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
|
||||
root_logger.addHandler(handler)
|
||||
|
||||
|
||||
# 同时保持原有的ragAnything日志记录器配置
|
||||
logger = logging.getLogger('ragAnything')
|
||||
logger.setLevel(logging.INFO)
|
||||
if not logger.handlers:
|
||||
handler = logging.StreamHandler()
|
||||
handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
|
||||
logger.addHandler(handler)
|
||||
# 控制台输出处理器
|
||||
console_handler = logging.StreamHandler()
|
||||
console_handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
|
||||
logger.addHandler(console_handler)
|
||||
# 循环滚动文件处理器(控制在200K左右)
|
||||
file_handler = RotatingFileHandler(
|
||||
'raganything.log',
|
||||
maxBytes=200*1024, # 200KB
|
||||
backupCount=5, # 最多保留5个备份文件
|
||||
encoding='utf-8',
|
||||
delay=True # 延迟创建文件,直到有日志输出
|
||||
)
|
||||
file_handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
|
||||
logger.addHandler(file_handler)
|
||||
|
||||
|
||||
async def main():
|
||||
|
Reference in New Issue
Block a user