Skip to content

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

@the42

Description

@the42

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions