feat(api): add logging configuration and mount routers

Why:
- Need structured logging for debugging query pipeline
- Need to mount benchmarking router

Changes:
- Added logging.basicConfig() with INFO level
- Mounted benchmarking router
- Registered QueryError exception handler
This commit is contained in:
2026-07-26 12:06:25 +03:30
parent cbaa72b420
commit b18ecdcd0c

View File

@@ -1,17 +1,28 @@
"""FastAPI app factory. Composes all domain routers and middleware."""
import logging
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from src.core.exceptions import (
ChunkingError,
BenchmarkError,
QueryError,
chunking_exception_handler,
benchmark_exception_handler,
)
from src.documents.routes import router as documents_router
from src.benchmarking.routes import router as benchmarking_router
from src.storage.sqlite import init_db
# Configure logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
def create_app() -> FastAPI:
"""Create and configure the FastAPI application.
@@ -40,9 +51,11 @@ def create_app() -> FastAPI:
# Register exception handlers
app.add_exception_handler(ChunkingError, chunking_exception_handler)
app.add_exception_handler(BenchmarkError, benchmark_exception_handler)
app.add_exception_handler(QueryError, benchmark_exception_handler)
# Mount domain routers
app.include_router(documents_router)
app.include_router(benchmarking_router)
return app