feat:更改配置文件

This commit is contained in:
2025-10-20 15:43:03 +08:00
parent 132fbb13b7
commit 398ad56933
3 changed files with 9 additions and 34 deletions

View File

@@ -3,18 +3,13 @@ import sys
from fluent import sender
from loguru import logger
from pathlib import Path
from config.setting import settings
FLUENTD_HOST = 'host.docker.internal'
FLUENTD_HOST = settings.FLUENTD_HOST
FLUENTD_PORT = 24224
TOPIC_TAG = 'blog-service'
# 日志目录
LOG_DIR = Path(__file__).parent.parent / "logs"
LOG_DIR.mkdir(exist_ok=True)
# 日志级别
LOG_LEVEL = settings.LOG_LEVEL.upper()
@@ -88,30 +83,6 @@ logger.add(
diagnose=True # 显示诊断信息
)
# # 添加文件处理器 - 常规日志
# logger.add(
# sink=LOG_DIR / "app.log",
# level="INFO",
# format=FILE_FORMAT,
# rotation="10 MB", # 日志文件大小达到10MB时自动分割
# retention="7 days", # 保留7天的日志
# compression="zip", # 归档时压缩为zip
# enqueue=True, # 异步写入
# serialize=False, # 不使用JSON格式
# )
#
# # 添加文件处理器 - 错误日志
# logger.add(
# sink=LOG_DIR / "error.log",
# level="ERROR",
# format=FILE_FORMAT,
# rotation="10 MB",
# retention="30 days",
# compression="zip",
# enqueue=True,
# serialize=False,
# )
atexit.register(fluent_sender.close)
# 导出配置好的logger