This commit is contained in:
2026-05-14 16:56:18 +08:00
parent d38a4630dd
commit 224330598a
15 changed files with 1151 additions and 277 deletions
+1 -6
View File
@@ -74,15 +74,10 @@ async def log_requests(request: Request, call_next):
status = response.status_code
if status >= 400:
auth_header = request.headers.get("authorization", "")
token_preview = ""
if auth_header.startswith("Bearer "):
token_raw = auth_header[7:]
token_preview = token_raw[:20] + "..." if len(token_raw) > 20 else token_raw
logger.warning(
f"[HTTP] {request.method} {request.url.path} -> {status} "
f"({duration:.2f}s) "
f"token={token_preview or 'none'}"
f"client={request.client.host if request.client else 'unknown'}"
)
return response