diff --git a/app/main.py b/app/main.py index f3f5995..384afa6 100644 --- a/app/main.py +++ b/app/main.py @@ -8,6 +8,7 @@ from app.core.response import error_response from fastapi import HTTPException from app.middleware.request_logger import RequestLoggerMiddleware from app.core.response import CustomJSONResponse +import logging # 创建数据库表 Base.metadata.create_all(bind=engine) @@ -66,6 +67,7 @@ async def health_check(): @app.exception_handler(RequestValidationError) async def validation_exception_handler(request, exc): + logging.exception(f"请求参数错误: {str(exc)}") return CustomJSONResponse( status_code=400, content=error_response( @@ -76,6 +78,7 @@ async def validation_exception_handler(request, exc): @app.exception_handler(HTTPException) async def http_exception_handler(request, exc): + logging.exception(f"HTTP异常: {str(exc)}") return CustomJSONResponse( status_code=exc.status_code, content=error_response(