common icon indicating copy to clipboard operation
common copied to clipboard

Logging: avoid expensive formatting when level is disabled.

Open bboreham opened this issue 4 years ago • 0 comments

This function: https://github.com/weaveworks/common/blob/53b72409d8e7fd53dcac17c6e8d8149bb3c8bc43/logging/gokit.go#L39-L41

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 avatar Oct 12 '21 13:10 bboreham