37 ms·
Actually, the % syntax eagerly evaluates the log string, you need to pass the variables as arguments to the logging function like this: logger.debug("bla: %s",
by Hasnep 2y ago
Actually, the % syntax eagerly evaluates the log string, you need to pass the variables as arguments to the logging function like this: logger.debug("bla: %s", myvar).
It's such a subtle difference that I only notice it when my IDE underlines it :/
- zelphirkalt 2y agoYou are right! I mixed them up as well. Here is a good source: https://blog.pilosus.org/posts/2020/01/24/python-f-strings-in-logging/ https://blog.pilosus.org/posts/2020/01/24/python-f-strings-i... (not mine)