Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind data to the request finished log event #39

Closed
prik2693 opened this issue Jun 16, 2020 · 4 comments · Fixed by #40
Closed

Bind data to the request finished log event #39

prik2693 opened this issue Jun 16, 2020 · 4 comments · Fixed by #40

Comments

@prik2693
Copy link

prik2693 commented Jun 16, 2020

Django Structlog request middleware logs an event ‘request_finished’ when a request ends with 200 status, would like to tmp bind additional parameters to this event log line.

Currently it’s not supported, is there way we can achieve this?

@prik2693 prik2693 changed the title Bind certain data to the request finished log event Bind data to the request finished log event Jun 16, 2020
@jrobichaud
Copy link
Owner

I could create a signal pretty much like bind_extra_request_metadata that would allow you to do the same but just before the request_finished and request_failed

Can this do?

bind_extra_request_metadata: https://django-structlog.readthedocs.io/en/latest/getting_started.html#extending-request-log-metadata

@prik2693
Copy link
Author

Yup, sth like this signal could work.

@jrobichaud
Copy link
Owner

I added two new signals:
https://django-structlog.readthedocs.io/en/latest/api_documentation.html#django_structlog.signals.bind_extra_request_finished_metadata

The fix will be in 1.5.5 that will be released shortly.

@jrobichaud
Copy link
Owner

@prik2693, my example are a little poor, only binding the user email. If you could provide me some awesome examples that would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants