fix(server): tolerate malformed request logging

This commit is contained in:
Frank Song
2026-05-24 18:02:24 +08:00
committed by nesquena-hermes
parent 2e876ea229
commit 618e1a5da8
3 changed files with 26 additions and 2 deletions

View File

@@ -232,8 +232,8 @@ class Handler(BaseHTTPRequestHandler):
duration_ms = round((time.time() - getattr(self, '_req_t0', time.time())) * 1000, 1)
record = _json.dumps({
'ts': time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()),
'method': self.command or '-',
'path': self.path or '-',
'method': getattr(self, 'command', None) or '-',
'path': getattr(self, 'path', None) or '-',
'status': int(code) if str(code).isdigit() else code,
'ms': duration_ms,
})