The logging statement has the call of the form logging.(format_string % (format_args...))
. For such calls, it is recommended to leave string interpolation to the logging method itself and be written as logging.(format_string, format_args...)
so that the program may avoid incurring the cost of the interpolation in those cases in which no message will be logged.
For more details, see PEP 282.
Not Preferred:
logger.info("This is a log message %s %d %d" % (msg, foo, bar))
Preferred:
logger.info("This is a log message %s %d %d", msg, foo, bar)