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

Run Enricher after next to allow access to request specific context information #26

Open
bumi opened this issue May 7, 2023 · 1 comment
Labels
question Further information is requested

Comments

@bumi
Copy link

bumi commented May 7, 2023

Currently it is not possible to use the Enricher to log context specific information that is added from other middlewares like for example the user ID.

Could calling the Enricher be moved to after the next() call to be able to log such information?

For example I have a middleware that loads sets the UserID in the context and wanted to add this information to the request logs.

Enricher: func(c echo.Context, logger zerolog.Context) zerolog.Context {
  userId := c.Get("UserID")
  if userId != nil {
    return logger.Str("user_id", userId.(string))
  }
  return logger.Str("user_id", "")
}
@ziflex
Copy link
Owner

ziflex commented May 8, 2023

Hey, why don't you put that middleware before the logger middleware?
In this case, enricher will have all required data.

@ziflex ziflex added the question Further information is requested label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants