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

wai-extra logging middleware should optionally log request before response is constructed #856

Open
sordina opened this issue Oct 17, 2021 · 2 comments

Comments

@sordina
Copy link
Contributor

sordina commented Oct 17, 2021

Waiting for the response before logging has issues:

  • Exceptions can prevent logging
  • Long response times delay seeing corresponding request logs

This makes using logging for development/debugging annoying and sometimes impossible.

Ideally the logging datastructures should be partitioned into request/response and middleware should be provided or be able to be configured to log the request as it arrives. For compatibility the full request/response information could still be logged once the response is generated if that makes sense.

Happy to put together a PR if people agree with this.

@snoyberg
Copy link
Member

No objection from me, seems reasonable. PR welcome, though it should avoid breaking existing application behavior.

@sordina
Copy link
Contributor Author

sordina commented Oct 19, 2021

@snoyberg Something like this? #857

New logging output looks like:

PRELOGGING REQUEST: GET /favicon.ico
  Accept: */*
GET /favicon.ico
  Accept: */*
  Status: 404 Not Found 0.000098s

if option is enabled.

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

No branches or pull requests

2 participants