日志记录模块在日志消息旁边自动显示关闭信息:
logging.basicConfig(format='%(levelname)s {%(filename)s:%(lineno)s} in %(funcName)s: %(message)s', level=logging.DEBUG)
我想包括从脚本运行时开始算起的秒数。日志模块提供 msecs
但我如何在此格式字符串中包含自开始以来的秒数?
最佳答案
在 documented logrecord attributes :
relativeCreated %(relativeCreated)d
Time in milliseconds when the LogRecord was created, relative to
the time the logging module was loaded.
关于python - 以自定义时间格式记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34621798/