feat: 引入 Loguru
This commit is contained in:
+7
-1
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user