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

funcr: Fix bug in repeated calls to WithValues #121

Merged
merged 1 commit into from
Nov 25, 2021
Merged

Conversation

thockin
Copy link
Contributor

@thockin thockin commented Nov 24, 2021

When using RenderValuesHook we need to save the raw value, not the
rendered form.

Fixes #120

@pohly let's not sit on it too long - we can tag a 1.2.1 maybe next week?

@DazWilkin FYI

When using `RenderValuesHook` we need to save the raw value, not the
rendered form.
@pohly pohly merged commit eeeb624 into go-logr:master Nov 25, 2021
@DazWilkin
Copy link

Thank you!

Will try this tomorrow.

@DazWilkin
Copy link

Works for me! Thank you.

Revert to the naive renderLabels:

func(kvList []interface{}) []interface{} {
  return []interface{}{loggingLabels, funcr.PseudoStruct(kvList)}
}

Bumped go-logr to github.com/go-logr/logr v1.2.1-0.20211125105631-eeeb6242dad5

Code effectively:

j := NewStructuredLogger()
j = j.WithValues("foo", "X")
j = j.WithValues("bar", "Y")

Deployed to Cloud Run (one of the services that supports structured logging):

jsonPayload:
  level: 0
  logger: structured-logging
  msg: test
  ts: '2021-11-30 17:34:36.639675'
labels: # <--- CORRECT
  bar: Y
  foo: X
sourceLocation:
  file: main.go
  function: main.main
  line: '127'

@thockin
Copy link
Contributor Author

thockin commented Nov 30, 2021

Thanks for the confirmation

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.

[funcr.NewJSON] Naive RenderValuesHook incorrectly triggered recursive labels
3 participants