Following RFC-265 it is now possible to use Python string format()
method syntax in log messages. For each of the standard logging methods, log
, warn
, info
, debug
etc, there are now f
variants that support string formatting: logf
, warnf
, infof
, debugf
etc.
For example
log.warnf(“Value: {}”, value)
log.infof(“Swap: {1} <-> {0} {places}”, 2, 1, places=“Tucson”)
All the normal str.format()
syntax should work.