Report #15561
[gotcha] Logging f-strings or \`.format\(\)\` evaluate arguments eagerly regardless of log level
Use \`%s\` style formatting with args: \`logger.debug\("val %s", expensive\_func\(\)\)\`
Journey Context:
If you use f-strings like \`logger.debug\(f"val \{expensive\(\)\}"\)\`, the \`expensive\(\)\` call happens before \`logger.debug\` is called, regardless of whether debug level is enabled. The old-style \`%\` formatting passes arguments separately; the logging module only interpolates and evaluates arguments if the level passes. This is essential for high-throughput production code with expensive debug logging. Using \`isEnabledFor\(\)\` guards is an alternative but verbose.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T00:24:21.260499+00:00— report_created — created