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

handler which adds eventid always at root level, not within a WithGroup #5

Open
the42 opened this issue Oct 24, 2023 · 3 comments
Open

Comments

@the42
Copy link

the42 commented Oct 24, 2023

I am banging my head in this seemingly easy and as I think not unreasonable issue.

  • I would like to create a new slog handler which adds a field eventID with an outomatically added UUID

    Achieved, writing custom handler type an custom Handler which adds a new field. Alternatively some trickery with ReplaceAttr also get's me there, Handler is cleaner though.

  • I would like to add further logging attributes into a group "custom", therefore I call myslogderivedlogger.WithGroup("custom").

    Here it get's funny though, as the field eventid is now added as custom.eventID instead at the "root" level, at the root level there is no more eventId

Would your slog middleware help me in getting there?

@the42 the42 changed the title handler which adds eventid but doesn't when called Withgroup handler which adds eventid always at root level, not within a WithGroup Oct 24, 2023
@samber
Copy link
Owner

samber commented May 11, 2024

did you write

myslogderivedlogger.WithGroup("custom")

or

myslogderivedlogger = myslogderivedlogger.WithGroup("custom")

?

@the42
Copy link
Author

the42 commented May 12, 2024 via email

@samber
Copy link
Owner

samber commented May 12, 2024

Could you please write a short demo of the bug?

i did it many times, without any issue

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