drf-api-tracking icon indicating copy to clipboard operation
drf-api-tracking copied to clipboard

Using this with Django Logger.

Open elebumm opened this issue 5 years ago • 2 comments

First, I want to say thank you for maintaining this package.

I wanted to know about ways I can use this package to integrate with the Django Logger, more specifically wachtower. I am wanting to use AWS CloudWatch to track API usage. Since I have a big application at the moment, would I have to go into each view, add the mixin and then override the handle_log function or is there a way I can set this by default somewhere?

Appreciate the help. Love the package. 😊

elebumm avatar Nov 26 '20 03:11 elebumm

I think you could create a new view:

class LoggingView(LoggingMixin, generics.GenericAPIView):
    def handle_log():
   

Then update all your existing views to be derived from this view and you can set the handle_log in just one place...

lingster avatar Nov 30 '20 00:11 lingster

@elebumm : did you manage to work out a solution? One other option is to create a django middleware class and add that in your middleware so every call could be logged from there.

lingster avatar May 01 '21 09:05 lingster