mirror of
https://github.com/ThePhaseless/Byparr.git
synced 2025-03-15 09:50:20 +08:00
better logging
This commit is contained in:
parent
d33af063da
commit
7029fd48f1
@ -1,4 +1,5 @@
|
|||||||
import time
|
import time
|
||||||
|
from http import HTTPStatus
|
||||||
|
|
||||||
from starlette.middleware.base import BaseHTTPMiddleware
|
from starlette.middleware.base import BaseHTTPMiddleware
|
||||||
|
|
||||||
@ -20,5 +21,9 @@ class LogRequest(BaseHTTPMiddleware):
|
|||||||
response = await call_next(request)
|
response = await call_next(request)
|
||||||
process_time = time.perf_counter() - start_time
|
process_time = time.perf_counter() - start_time
|
||||||
|
|
||||||
logger.info(f"Done {request_body.url} in {process_time:.2f}s")
|
if response.status_code == HTTPStatus.OK:
|
||||||
|
logger.info(f"Done {request_body.url} in {process_time:.2f}s")
|
||||||
|
else:
|
||||||
|
logger.info(f"Failed {request_body.url} in {process_time:.2f}s")
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
Loading…
x
Reference in New Issue
Block a user