feat: 引入 Loguru

This commit is contained in:
2026-09-29 00:47:57 +08:00
parent 0fdde8c3e6
commit 437fcd74b1
8 changed files with 139 additions and 31 deletions
+7 -1
View File
@@ -4,13 +4,16 @@ import asyncio
from contextlib import asynccontextmanager
from fastapi import FastAPI
from loguru import logger
from app.api.agent import router
from app.core.exceptions import register_exception_handlers
from app.core.logging import setup_logging
@asynccontextmanager
async def lifespan(application: FastAPI):
setup_logging()
from app.clients.decision import close_decision_engine
from app.observability.tracing import flush_tracing
from app.processor.graph import build_graph
@@ -24,7 +27,10 @@ async def lifespan(application: FastAPI):
try:
await close_decision_engine()
finally:
await asyncio.to_thread(flush_tracing)
try:
await asyncio.to_thread(flush_tracing)
finally:
await logger.complete()
def create_app() -> FastAPI: