移除HTTP详情请求日志
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
"""请求日志路由 - 查看 HTTP 请求/响应详情日志"""
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from typing import Optional
|
||||
|
||||
from ..deps import get_current_user
|
||||
from ..permissions import user_has_permission
|
||||
from utils.http_logger import read_http_logs, clear_http_logs
|
||||
|
||||
router = APIRouter(prefix="/api/logs", tags=["日志"])
|
||||
|
||||
|
||||
@router.get("/http")
|
||||
def list_http_logs(
|
||||
limit: int = Query(50, ge=1, le=500),
|
||||
offset: int = Query(0, ge=0),
|
||||
category: Optional[str] = None,
|
||||
level: Optional[str] = None,
|
||||
keyword: Optional[str] = None,
|
||||
current=Depends(get_current_user),
|
||||
):
|
||||
"""查看 HTTP 请求/响应详情日志(需要审计日志查看权限)"""
|
||||
if not user_has_permission(current, "audit:view"):
|
||||
# 运营也可以查看请求日志(用于排查登录问题)
|
||||
if not user_has_permission(current, "login:batch"):
|
||||
raise HTTPException(status_code=403, detail="无权限")
|
||||
|
||||
items, total = read_http_logs(
|
||||
limit=limit,
|
||||
offset=offset,
|
||||
category=category,
|
||||
level=level,
|
||||
keyword=keyword,
|
||||
)
|
||||
return {"items": items, "total": total}
|
||||
|
||||
|
||||
@router.delete("/http")
|
||||
def clear_http_logs_api(current=Depends(get_current_user)):
|
||||
"""清空 HTTP 请求/响应详情日志"""
|
||||
if not user_has_permission(current, "audit:view"):
|
||||
if not user_has_permission(current, "login:batch"):
|
||||
raise HTTPException(status_code=403, detail="无权限")
|
||||
|
||||
count = clear_http_logs()
|
||||
return {"success": True, "cleared": count}
|
||||
Reference in New Issue
Block a user