Writing to Django Using / ip User

I use the "logging" module to log a very large number of messages. I would like to add "user" (request.user) to the log. But while it is available in the viewing function, I do not want to pass it on to all the helpers.

Does anyone know a way to this? [I was thinking about somehow going along the track until I find a function with a request in my arguments.

Thank you in advance

+3
source share
1 answer

The hacker way to do this is to insert the request (or request.user) into threadlocal storage .

- . , , .

+3

Source: https://habr.com/ru/post/1724850/


All Articles