python - 以自定义时间格式记录

标签 python python-2.7

日志记录模块在日志消息旁边自动显示关闭信息:

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/

相关文章:

python - 两个Python类实例相互引用

python - Python中具有更高优先级的优先级队列

python - 比较测验的两种不同解决方案

python - Selenium 在 Python 中不起作用

python - Pandas HDFStore : difference between using the select function and direct access

python - 在Python中合并两个csv文件

python - 如何让我的变量脱离这个循环? - blender

python - oauth2client/appengine.py 返回 "InvalidResponseError: header values must be str, got ' unicode'"与 webapp2/python27/wsgi

python - 将包含 2 个值的列拆分为 pandas df 中的不同列

python - 在 Keras 中编写自定义 MSE 损失函数