Skip to content

Commit ef147d5

Browse files
committed
improve logging for rate limit exceeded messages
1 parent 845de76 commit ef147d5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

blueprints/v0.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from flask import current_app, json
55
from os import environ as env
66

7+
from flask_limiter.util import get_remote_address
78
from helpers import respond
89
from flask import Blueprint, abort, jsonify, request
910
from werkzeug.exceptions import HTTPException
@@ -565,7 +566,8 @@ def after_request(response):
565566
# https://flask-limiter.readthedocs.io/en/stable/#custom-rate-limit-exceeded-responses
566567
@blueprint.errorhandler(429)
567568
def ratelimit_handler(e):
568-
print(e)
569+
current_app.logger.warning(e)
570+
current_app.logger.warning("User at address " + get_remote_address() + "exceeded rate limit of " + e.description)
569571
return respond(
570572
make_error_object(429, title="Ratelimit Exceeded",
571573
message="ratelimit of " + e.description + " exceeded"),

0 commit comments

Comments
 (0)