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

JSON logger with %v generate bad value #3837

Closed
StephaneBrillant opened this issue Feb 25, 2021 · 1 comment · Fixed by #3847
Closed

JSON logger with %v generate bad value #3837

StephaneBrillant opened this issue Feb 25, 2021 · 1 comment · Fixed by #3847

Comments

@StephaneBrillant
Copy link
Contributor

At 2 places the %v macro is used with the logger and is not supported

level.Warn(logger).Log("msg", "Duplicate store address is provided - %v", addr)

level.Warn(logger).Log("msg", "duplicate query address is provided - %v", u.String())

What happened:
Logs generates result in dynamic key with MISSING value.
ex:

{"msg":"Duplicate store address is provided - %v","test":"(MISSING)"}

What you expected to happen:
Json logging play well with ElasticSearch type mapping. No dynamic key with MISSING value is reported

Proposed fix
Replace %v by string concatenation
ex: logger.Log("msg", "Duplicate store address is provided - " + addr)

@yeya24
Copy link
Contributor

yeya24 commented Feb 26, 2021

Thanks for catching this! Would you like to open a pr to fix it?

We can just change it to level.Warn(logger).Log("msg", "Duplicate store address is provided", "addr", addr).

I am wondering if there is already a static linter for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants