dabapps / django-log-request-id

Django middleware and log filter to attach a unique ID to every log message generated as part of a request
BSD 2-Clause "Simplified" License
371 stars 64 forks source link

Add documentation how to access the request ID in views #49

Closed moritz89 closed 2 years ago

moritz89 commented 4 years ago

When integrating the middleware, I first tried to access the request ID in views through the headers array in the request request.headers["X-Request-ID"]. It would be helpful if this were documented in the readme instead of having to look at the source code to see that it is saved as request.id.

Is this already documented somewhere or should I create a pull request (that also extends the example)?

j4mie commented 4 years ago

Hi, thanks for opening the issue. I think documenting that explicitly is a good idea! Happy to review a PR 👍

moritz89 commented 3 years ago

Hey @j4mie, first of all happy new year and wanted to ask how that pull request is looking like :D https://github.com/dabapps/django-log-request-id/pull/50

j4mie commented 3 years ago

Hi @moritz89. The tests are failing on your PR. If you could just revert the changes to the test code (ie only update the documentation) then they should pass.

roysmith commented 3 years ago

It would be good if this was accepted. I was just looking at using this and scratching my head over exactly this question.

BTW, the alternative I was looking at is nigma / django-request-id. It has the advantage of documenting how to access the ID :-) On the down side, it looks like an abandoned project, so this project seems like the way to go.

j4mie commented 2 years ago

This is now fixed 🎉 see https://github.com/dabapps/django-log-request-id/commit/745618bf40935f2293b113cc7fc37ace1633294f