kazu-yamamoto / logger

A fast logging system for Haskell
159 stars 68 forks source link

Add ability to log current user via getter #198

Closed wolfgangwalther closed 2 years ago

wolfgangwalther commented 2 years ago

The "Common Log Format" used by apache is supposed to show the current user "as determined by HTTP authentication". This is not implemented in wai-logger, yet:

https://github.com/kazu-yamamoto/logger/blob/cde8404e9f37a0202655f99da04fd5326d9ea6c7/wai-logger/Network/Wai/Logger/Apache.hs#L81

The second - is supposed to be the user.

Since there is, afaik, no "WAI standard" on how to get that user, this PR adds the ability to pass in a getter to initLogger which will then read the current user from the Request. This would allow to pass in a helper around wai-middleware-auth's getAuthUser or allow to do something similar in PostgREST (https://github.com/PostgREST/postgrest/pull/1988).

If this was merged, I'd follow up with a PR to wai-extra to make it available in mkRequestLogger.

kazu-yamamoto commented 2 years ago

Merged. Thanks. If you want to have a new release, please let me know.

kazu-yamamoto commented 2 years ago

A new version has been released.