mirror of
https://github.com/snailyp/gemini-balance.git
synced 2026-09-04 23:19:17 +08:00
style(router): 优化错误日志路由代码格式
- 移除多余的空白行 - 简化删除所有错误日志的日志记录逻辑 - 统一代码缩进和空行格式
This commit is contained in:
@@ -192,10 +192,10 @@ async def delete_all_error_logs_api(request: Request):
|
|||||||
if not auth_token or not verify_auth_token(auth_token):
|
if not auth_token or not verify_auth_token(auth_token):
|
||||||
logger.warning("Unauthorized access attempt to delete all error logs")
|
logger.warning("Unauthorized access attempt to delete all error logs")
|
||||||
raise HTTPException(status_code=401, detail="Not authenticated")
|
raise HTTPException(status_code=401, detail="Not authenticated")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
deleted_count = await error_log_service.process_delete_all_error_logs()
|
await error_log_service.process_delete_all_error_logs()
|
||||||
logger.info(f"Successfully deleted all {deleted_count} error logs.")
|
logger.info("Successfully deleted all error logs.")
|
||||||
# No body needed for 204 response
|
# No body needed for 204 response
|
||||||
return Response(status_code=status.HTTP_204_NO_CONTENT)
|
return Response(status_code=status.HTTP_204_NO_CONTENT)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -203,8 +203,8 @@ async def delete_all_error_logs_api(request: Request):
|
|||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=500, detail="Internal server error during deletion of all logs"
|
status_code=500, detail="Internal server error during deletion of all logs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.delete("/errors/{log_id}", status_code=status.HTTP_204_NO_CONTENT)
|
@router.delete("/errors/{log_id}", status_code=status.HTTP_204_NO_CONTENT)
|
||||||
async def delete_error_log_api(request: Request, log_id: int = Path(..., ge=1)):
|
async def delete_error_log_api(request: Request, log_id: int = Path(..., ge=1)):
|
||||||
"""
|
"""
|
||||||
@@ -214,7 +214,7 @@ async def delete_error_log_api(request: Request, log_id: int = Path(..., ge=1)):
|
|||||||
if not auth_token or not verify_auth_token(auth_token):
|
if not auth_token or not verify_auth_token(auth_token):
|
||||||
logger.warning(f"Unauthorized access attempt to delete error log ID: {log_id}")
|
logger.warning(f"Unauthorized access attempt to delete error log ID: {log_id}")
|
||||||
raise HTTPException(status_code=401, detail="Not authenticated")
|
raise HTTPException(status_code=401, detail="Not authenticated")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
success = await error_log_service.process_delete_error_log_by_id(log_id)
|
success = await error_log_service.process_delete_error_log_by_id(log_id)
|
||||||
if not success:
|
if not success:
|
||||||
|
|||||||
Reference in New Issue
Block a user