具有多个参数的日志记录格式插值
Logging format interpolation with multiple arguments
pylint
产生以下警告:
logging-format-interpolation (W1202):
Use % formatting in logging functions and pass the % parameters as
arguments Used when a logging statement has a call form of
“logging.(format_string.format(format_args...))”. Such calls should
use % formatting instead, but leave interpolation to the logging
function by passing the parameters as arguments.
所以正确的记录方式是:logger.error('oops caused by %s', exc)
但是如何传递多个参数呢?有这样的东西:
logger.error('oops caused by %s %s')
(把exc_one
、exc_two
放在哪里?)
您应该将其作为普通位置参数传递
logger.error('oops caused by %s %s', exc_one, exc_two)
查看函数signature:
logging.error(msg, *args, **kwargs)
pylint
产生以下警告:
logging-format-interpolation (W1202):
Use % formatting in logging functions and pass the % parameters as arguments Used when a logging statement has a call form of “logging.(format_string.format(format_args...))”. Such calls should use % formatting instead, but leave interpolation to the logging function by passing the parameters as arguments.
所以正确的记录方式是:logger.error('oops caused by %s', exc)
但是如何传递多个参数呢?有这样的东西:
logger.error('oops caused by %s %s')
(把exc_one
、exc_two
放在哪里?)
您应该将其作为普通位置参数传递
logger.error('oops caused by %s %s', exc_one, exc_two)
查看函数signature:
logging.error(msg, *args, **kwargs)