feat(backend): RBAC admin roles + runtime logs service
This commit is contained in:
@@ -28,6 +28,8 @@ from app.api.router import api_router
|
||||
from app.dependencies import init_shared_services, cleanup_shared_services
|
||||
# 导入异常处理器和异常类
|
||||
from app.utils.response import AppException, app_exception_handler, success_response
|
||||
# 导入日志配置(运行期日志文件接线:standard SOP 第三阶段 · 运行期日志 D 页依赖)
|
||||
from app.utils.logging_config import setup_logging
|
||||
# 导入定时任务
|
||||
from app.tasks.reminder_task import check_unreplied_sessions
|
||||
|
||||
@@ -75,6 +77,18 @@ async def lifespan(app: FastAPI):
|
||||
在应用关闭时执行清理操作。
|
||||
"""
|
||||
# ===== 启动事件 =====
|
||||
# 运行期日志接线(standard SOP 第三阶段 · 运行期日志 D 页依赖):
|
||||
# 在 stdout handler 之外,将结构化 JSON 日志写入 settings.RUNTIME_LOG_DIR/wecom-it-desk.log
|
||||
# (RotatingFileHandler:单文件上限 20MB,保留 5 个备份,复用 JSONFormatter)。
|
||||
# 目录不可创建/写入时自动降级为仅 stdout,不阻塞启动。
|
||||
# 注:setup_logging 会清空 root logger 已有 handler(含模块级 basicConfig),
|
||||
# 并以 console(stdout) + 文件(JSON) 重新配置,避免重复输出。
|
||||
setup_logging(
|
||||
level=os.getenv("LOG_LEVEL", "INFO"),
|
||||
json_format=True,
|
||||
log_dir=settings.RUNTIME_LOG_DIR,
|
||||
)
|
||||
|
||||
logger.info("🚀 企微IT智能服务台启动中...")
|
||||
|
||||
# 校验关键配置项(防止生产环境忘记配置导致静默失败)
|
||||
|
||||
Reference in New Issue
Block a user