Skip to content

logr overriding and not duplicating values #345

@jlewi

Description

@jlewi

See: go-logr/logr#170

If you do "WithValues" multiple times for the same field, zapr will adds the field multiple times to the record.
I'm not sure that's what we want; we probably want to override the field with the latest value.

One way to deal with this would be to change how we pass "logr" along in contexts. Rather than passing along a logr with any values attached to it in context we could define a new interface

type LogR struct {
    log *LogR
    fields map[string]interface{}
}

We could then store the fields in map. We could override "WithValues" so that each time it gets called we reconstruct the logr.

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