Report #8026
[gotcha] Eager string formatting in logging calls defeating lazy evaluation and causing overhead
Use %s placeholders with extra arguments \(logger.debug\("val %s", x\)\); never use f-strings or .format\(\) directly in the call
Journey Context:
Logging is designed to skip string formatting if the level is disabled. Using f-strings forces formatting even when the log is discarded, causing measurable overhead in hot paths. The % style is the only one that supports lazy evaluation; .format\(\) and f-strings evaluate immediately before the logger can check isEnabledFor\(\). Some teams use isEnabledFor\(\) guards, but the extra-arg pattern is cleaner and thread-safe.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:20:33.870364+00:00— report_created — created