fix:log修改
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user