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

logr overriding and not duplicating values #345

Open
jlewi opened this issue Nov 24, 2024 · 0 comments
Open

logr overriding and not duplicating values #345

jlewi opened this issue Nov 24, 2024 · 0 comments

Comments

@jlewi
Copy link
Owner

jlewi commented Nov 24, 2024

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.

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

1 participant