Skip to content

Adding custom attribute support for http middleware #26

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

Merged
merged 76 commits into from
Apr 15, 2025
Merged

Conversation

manasachi
Copy link
Collaborator

@manasachi manasachi commented Mar 11, 2025

This PR allows extra attributes to be assigned to the logger.

  • CustomAttributes struct:

    • If specified, allows users to specify an initializer and assigner function. The initializer should initialize the custom attributes and return then as a map[string]interface{}.
    • At the end of ServeHTTP(), the assigner function takes those initialized attributes as a parameter and updates values as needed
  • loggingMiddleware takes source as a field. If specified, it is assigned. Otherwise, the default is "CtxLog"

We can reduce the scope of this PR for context logging (source: CtxLog) and create a folder which allows users to add custom attributes to the logger.

@manasachi manasachi marked this pull request as ready for review March 12, 2025 16:33
@toma3233 toma3233 merged commit 2389116 into main Apr 15, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

4 participants