diff --git a/src/logging.py b/src/logging.py index 42f869c..2207241 100644 --- a/src/logging.py +++ b/src/logging.py @@ -129,6 +129,9 @@ def configure_logging(): access_logger.handlers = [] access_logger.propagate = False + # set uvicorn access log level to warning + logging.getLogger("uvicorn.access").setLevel(logging.WARNING) + # sometimes the slack client can be too verbose logging.getLogger("slack_sdk.web.base_client").setLevel(logging.CRITICAL) diff --git a/src/main.py b/src/main.py index 9f604b0..2562611 100644 --- a/src/main.py +++ b/src/main.py @@ -40,19 +40,18 @@ log = logging.getLogger(__name__) # we configure the logging level and format configure_logging() -# we define the exception handlers -exception_handlers = {Exception: handle_exception} - # we create the ASGI for the app -app = FastAPI(exception_handlers=exception_handlers, openapi_url="", title="LCCA API", +app = FastAPI(openapi_url="", title="LCCA API", description="Welcome to LCCA's API documentation!", version="0.1.0") app.state.limiter = limiter -app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler) + +# we define the exception handlers +app.add_exception_handler(Exception, handle_exception) app.add_exception_handler(HTTPException, handle_exception) +app.add_exception_handler(StarletteHTTPException, handle_exception) app.add_exception_handler(RequestValidationError, handle_exception) -app.add_exception_handler(SQLAlchemyError, handle_exception) -app.add_middleware(GZipMiddleware, minimum_size=2000) +app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler) from src.context import set_request_id, reset_request_id, get_request_id