lingster / drf-api-tracking

Fork of aschn/drf-tracking so that we can maintain and release newer versions
ISC License
275 stars 57 forks source link

Using this with Django Logger. #43

Open elebumm opened 3 years ago

elebumm commented 3 years ago

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. 😊

lingster commented 3 years ago

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 commented 3 years ago

@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.