jsocol / django-ratelimit

Cache-based rate-limiting for Django
https://django-ratelimit.readthedocs.io/en/latest/
Other
1.06k stars 188 forks source link

Provide information about which specific rate limits were counted #185

Open zhanghao0809 opened 5 years ago

zhanghao0809 commented 5 years ago

I use multiple decorators in my class before method.I want to write the detail to the log file when the request is blocked,Like "xxx IP is blocked" or "xx user is blocked " .But I have no idea how to know which decorator the API triggers in the method。

jsocol commented 5 years ago

Right now, it's not possible. I'm going to rename this issue to capture the request. (It's come up before, so I actually thought there was one already.)

lomadapraveenreddy commented 1 month ago

Hi @jsocol, I created a pr for this issue. I implemented it like this, user sends an object of RatelimitLogger class which takes name of the logger defined in settings, level and the format of the message to log. When rate is limited and logger object is sent to the ratelimit decorator then we log them.