日志记录模块在日志消息旁边提供自动显示关闭信息:
logging.basicConfig(format='%(levelname)s {%(filename)s:%(lineno)s} in %(funcName)s: %(message)s', level=logging.DEBUG)
我希望包含从脚本运行时开始的秒数。日志记录模块提供msecs
但是如何包含自此格式字符串开始以来的秒数?
答案 0 :(得分:1)
在documented logrecord attributes:
relativeCreated %(relativeCreated)d
Time in milliseconds when the LogRecord was created, relative to
the time the logging module was loaded.