Fix duplicated logging

This commit is contained in:
2025-09-29 17:57:20 +03:00
Unverified
parent d48447a352
commit f998c65d25
4 changed files with 50 additions and 29 deletions
+25 -1
View File
@@ -1,10 +1,34 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import logging
from contextlib import asynccontextmanager
from migration import run_migrations
from routes import account, messaging, profile, push
# Configure logging
logger = logging.getLogger("uvicorn.error")
logger.handlers.clear()
@asynccontextmanager
async def lifespan(app: FastAPI):
"""Handle application lifespan events."""
# Startup
try:
logger.info("Starting database migration check...")
run_migrations()
logger.info("Database migrations completed successfully.")
except Exception as e:
logger.error(f"Failed to run database migrations: {e}")
raise
yield
# Shutdown (if needed in the future)
# logger.info("Application shutdown")
# Инициализация FastAPI
app = FastAPI(title="PixelChat")
app = FastAPI(title="FromChat", lifespan=lifespan)
# CORS
app.add_middleware(