From b18ecdcd0c087ecd44ce0c9a1c53d8c2d16f1dd8 Mon Sep 17 00:00:00 2001 From: Mahdi Bazrafshan Date: Sun, 26 Jul 2026 12:06:25 +0330 Subject: [PATCH] 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 --- src/main.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main.py b/src/main.py index f319a73..49622d2 100644 --- a/src/main.py +++ b/src/main.py @@ -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