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:
13
src/main.py
13
src/main.py
@@ -1,17 +1,28 @@
|
|||||||
"""FastAPI app factory. Composes all domain routers and middleware."""
|
"""FastAPI app factory. Composes all domain routers and middleware."""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
from src.core.exceptions import (
|
from src.core.exceptions import (
|
||||||
ChunkingError,
|
ChunkingError,
|
||||||
BenchmarkError,
|
BenchmarkError,
|
||||||
|
QueryError,
|
||||||
chunking_exception_handler,
|
chunking_exception_handler,
|
||||||
benchmark_exception_handler,
|
benchmark_exception_handler,
|
||||||
)
|
)
|
||||||
from src.documents.routes import router as documents_router
|
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
|
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:
|
def create_app() -> FastAPI:
|
||||||
"""Create and configure the FastAPI application.
|
"""Create and configure the FastAPI application.
|
||||||
@@ -40,9 +51,11 @@ def create_app() -> FastAPI:
|
|||||||
# Register exception handlers
|
# Register exception handlers
|
||||||
app.add_exception_handler(ChunkingError, chunking_exception_handler)
|
app.add_exception_handler(ChunkingError, chunking_exception_handler)
|
||||||
app.add_exception_handler(BenchmarkError, benchmark_exception_handler)
|
app.add_exception_handler(BenchmarkError, benchmark_exception_handler)
|
||||||
|
app.add_exception_handler(QueryError, benchmark_exception_handler)
|
||||||
|
|
||||||
# Mount domain routers
|
# Mount domain routers
|
||||||
app.include_router(documents_router)
|
app.include_router(documents_router)
|
||||||
|
app.include_router(benchmarking_router)
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user