fix:log修改

This commit is contained in:
2025-11-20 16:33:48 +08:00
parent 15a4fa618f
commit 3234b0c2e9
4 changed files with 14 additions and 23 deletions

View File

@@ -49,6 +49,17 @@ export function auditLogMiddleware(req: Request, res: Response, next: NextFuncti
res.on('finish', () => {
const duration = Date.now() - start;
const status = res.statusCode;
const url = req.originalUrl || req.url;
const isHealthCheck =
req.method === 'GET' &&
(url === '/api/health' || url === '/health' || url.startsWith('/api/health?') || url.startsWith('/health?'));
// Skip noisy health-check logs unless there is a server error
if (isHealthCheck && status < 500) {
return;
}
let out: unknown = responseBody;
if (typeof out === 'string') {
// Try to avoid logging massive HTML or binary-like outputs