Skip to content

Commit

Permalink
Merge pull request #2711 from locustio/lower-log-levels-for-exception…
Browse files Browse the repository at this point in the history
…s-in-flask,-especially-for-404-and-lower

Lower log levels for exceptions in flask
  • Loading branch information
cyberw authored May 13, 2024
2 parents 12e4f57 + c4bea34 commit d35f1fa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions locust/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ def __init__(
@app.errorhandler(Exception)
def handle_exception(error):
error_message = str(error)
logger.log(logging.CRITICAL, error_message)
return make_response(error_message, getattr(error, "code", 500))
error_code = getattr(error, "code", 500)
logger.log(logging.INFO if error_code <= 404 else logging.ERROR, error_message)
return make_response(error_message, error_code)

@app.route("/assets/<path:path>")
def send_assets(path):
Expand Down

0 comments on commit d35f1fa

Please sign in to comment.