Skip to content

Commit

Permalink
Add conditional logging
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaweedbrainCY committed Dec 2, 2024
1 parent eee1873 commit 7b90b9a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ def clean_expired_refresh_token():
@flask.after_request
def after_request(response):
from Utils import utils
logging.info(f"Completed request ip={utils.get_ip(request)} gw={request.remote_addr} url={request.url} method={request.method} status={response.status_code}")
if response.status_code >= 500:
logging.error(f"Completed request ip={utils.get_ip(request)} gw={request.remote_addr} url={request.url} method={request.method} status={response.status_code}")
elif response.status_code >= 400:
logging.warning(f"Completed request ip={utils.get_ip(request)} gw={request.remote_addr} url={request.url} method={request.method} status={response.status_code}")
else :
logging.info(f"Completed request ip={utils.get_ip(request)} gw={request.remote_addr} url={request.url} method={request.method} status={response.status_code}")
return response


Expand Down

0 comments on commit 7b90b9a

Please sign in to comment.