Closed petedmarsh closed 1 year ago
Logging like this:
logger.debug("Hello, %s" % name)
causes the message string to always be interpolated even if the message is not going to be logged.
logger.debug("Hello, %s", name)
will mean the string is only ever interpolated if it will be logged.
In practice here this will make little difference if the log level is INFO or above.
See:
https://docs.python.org/3/howto/logging.html#optimization https://stackoverflow.com/questions/4148790/lazy-logger-message-string-evaluation
I realized I missed a bunch of cases using .format, have fixed those now.
.format
Logging like this:
causes the message string to always be interpolated even if the message is not going to be logged.
Logging like this:
will mean the string is only ever interpolated if it will be logged.
In practice here this will make little difference if the log level is INFO or above.
See:
https://docs.python.org/3/howto/logging.html#optimization https://stackoverflow.com/questions/4148790/lazy-logger-message-string-evaluation