Skip to content

refactor: no middleware for response logging #4062

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

steve-chavez
Copy link
Member

Benefits:

TODO:

  • Currently we vendor apacheLogStr, but might be possible to expose this function upstream. If not, it's not a big problem since the function is small.
  • Time in logging differs:
  Old: 127.0.0.1 - postgrest_test_anonymous [05/May/2025:01:39:57 -0500] "GET /projects HTTP/1.1" 200 212 "" "curl/7.81.0"
  New: 127.0.0.1 - postgrest_test_anonymous [2025-05-05 01:39:14.776911752 -05] "GET /projects HTTP/1.1" 200 212 "" "curl/7.81.0"
  • Otherwise the rest of the format is the same.

Benefits:

- Removes `unsafePerformIO` from Logger
- Reuses our cached time getter (`stateGetZTime`) instead of having another unnecessary one.
  See https://github.com/yesodweb/wai//blob/d50e1184600631a114e3d2ad119abdf0ef08834b/wai-extra/Network/Wai/Middleware/RequestLogger/Internal.hs#L22-L37.
- Reuses Observation module, simplified logic
- Will help with log buffering PostgREST#4061

TODO:

- [ ] Currently we vendor `apacheLogStr`, but might be possible to
  expose this function upstream. If not, it's not a big problem since
  the function is small.
- [ ] Time in logging differs a bit:
```
  Old: postgrest_test_anonymous [04/May/2025:14:43:06 -0500]
  New: postgrest_test_anonymous [2025-05-04 22:43:01.28098247 -05]
```
  + Otherwise all logging works the same.
- [ ] Auth error logging relies on old logger middleware
  + We might need to put `observer` in Auth.hs
  + Or otherwise try to combine this with PostgREST#4059
@taimoorzaeem
Copy link
Collaborator

Looks good 👍. I was thinking of adding some commits to this PR to quickly wrap this one up, but I am not sure how to do that.

@steve-chavez
Copy link
Member Author

I was thinking of adding some commits to this PR to quickly wrap this one up

@taimoorzaeem That would be great! Maybe you can open another PR based on this one?

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

Successfully merging this pull request may close these issues.

2 participants