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

Logging: avoid expensive formatting when level is disabled. #225

Closed
bboreham opened this issue Oct 12, 2021 · 1 comment
Closed

Logging: avoid expensive formatting when level is disabled. #225

bboreham opened this issue Oct 12, 2021 · 1 comment

Comments

@bboreham
Copy link
Collaborator

This function:

common/logging/gokit.go

Lines 39 to 41 in 53b7240

func (g gokit) Debugf(format string, args ...interface{}) {
level.Debug(g.Logger).Log("msg", fmt.Sprintf(format, args...))
}

will do the printf with all string formatting, memory allocation, etc., regardless of whether debug logging is enabled.

This appears to be the intention of go-kit/log/level; it does not expose any way to ask about levels outside of Log().
We could keep a note of which level is allowed, thus shortcut the Sprintf call above.

@bboreham
Copy link
Collaborator Author

I think this was fixed by #227.

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