feat(backend): 完善日志系统,支持按日期分目录存储
- 实现 logs/YYYY-MM-DD/ 日期文件夹结构 - 添加 success.log 和 failure.log 专用日志 - 使用 TimedRotatingFileHandler 实现按天切割 - 添加 log_success 和 log_failure 便捷函数 - 集成 markitdown 进行文件转换 - 优化文件存储路径,按项目ID分类存储 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -107,7 +107,7 @@ async def app_exception_handler(request: Request, exc: AppException):
|
||||
content=ApiResponse.fail(
|
||||
message=exc.message,
|
||||
error={"code": exc.code, "details": exc.details}
|
||||
).model_dump()
|
||||
).model_dump(mode='json')
|
||||
)
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ async def validation_exception_handler(request: Request, exc: RequestValidationE
|
||||
content=ApiResponse.fail(
|
||||
message="Validation error",
|
||||
error={"code": "VALIDATION_ERROR", "details": {"errors": errors}}
|
||||
).model_dump()
|
||||
).model_dump(mode='json')
|
||||
)
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ async def database_exception_handler(request: Request, exc: SQLAlchemyError):
|
||||
content=ApiResponse.fail(
|
||||
message="Database operation failed",
|
||||
error={"code": "DATABASE_ERROR"}
|
||||
).model_dump()
|
||||
).model_dump(mode='json')
|
||||
)
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ async def general_exception_handler(request: Request, exc: Exception):
|
||||
content=ApiResponse.fail(
|
||||
message="Internal server error",
|
||||
error={"code": "INTERNAL_ERROR"}
|
||||
).model_dump()
|
||||
).model_dump(mode='json')
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user