wilspi / comments-zeroes

0 stars 0 forks source link

p/django-middleware-to-log-requests/ #2

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Log requests and responses with Django Middleware

Write custom Django Middleware to log requests fields and respective responses in the log file

https://zeroes.dev/p/django-middleware-to-log-requests/

bastiaan85 commented 2 years ago

You should use time.monotonic() instead of time.time(). As when the system time would change during the request (eg user changed time or NTP time sync was applie) this request 'stopwatch' would give an incorrect result. time.monotic() is guaranteed to reflect the CPU time ticks and thus won't be affected by (clock) time changes.

alxvallejo commented 12 months ago

TypeError: init() missing 1 required positional argument: 'get_response'

bastiaan85 commented 12 months ago

@alxvallejo hard to debug without seeing your implementation, but this may be of help: https://copyprogramming.com/howto/typeerror-init-missing-1-required-positional-argument-get-response

LarryMartell commented 11 months ago

accessing the body on lime 29 fails with: *** django.http.request.RawPostDataException: You cannot access body after reading from request's data stream

bastiaan85 commented 11 months ago

accessing the body on lime 29 fails with: *** django.http.request.RawPostDataException: You cannot access body after reading from request's data stream

Are you using this in conjunction with an API framework like DRF or Ninja?

Mayyarkmp commented 1 day ago

I'm using this in conjunction with Ninja, is there any other configurations that are necessary?