merge commits

This commit is contained in:
Vladimir Mandic
2023-05-02 15:06:06 -04:00
parent cb4cff3929
commit 7a083d322b
13 changed files with 54 additions and 12 deletions
+2 -2
View File
@@ -39,7 +39,7 @@ def setup_middleware(app: FastAPI, cmd_opts):
res.headers["X-Process-Time"] = duration
endpoint = req.scope.get('path', 'err')
if cmd_opts.api_log and endpoint.startswith('/sdapi'):
log.info('API {t} {code} {prot}/{ver} {method} {endpoint} {cli} {duration}'.format( # pylint: disable=consider-using-f-string
log.info('API {t} {code} {prot}/{ver} {method} {endpoint} {cli} {duration}'.format( # pylint: disable=consider-using-f-string, logging-format-interpolation
t = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"),
code = res.status_code,
ver = req.scope.get('http_version', '0.0'),
@@ -58,8 +58,8 @@ def setup_middleware(app: FastAPI, cmd_opts):
"body": vars(e).get('body', ''),
"errors": str(e),
}
log.error(f"API error: {req.method}: {req.url} {err}")
if not isinstance(e, HTTPException) and err['error'] != 'TypeError': # do not print backtrace on known httpexceptions
log.error(f"API error: {req.method}: {req.url} {err}")
errors.display(e, 'HTTP API', [anyio, fastapi, uvicorn, starlette])
return JSONResponse(status_code=vars(e).get('status_code', 500), content=jsonable_encoder(err))