【发布时间】:2014-10-05 05:21:36
【问题描述】:
有关于在 python 日志中使用毫秒的问题,有关于如何使用 UTC 的问题,但我看不出如何将这两者结合起来。基于this 的问题,我如何使用UTC 时间而不是本地时间来记录?
def formatTime(self, record, datefmt=None):
ct = self.converter(record.created)
if datefmt:
s = time.strftime(datefmt, ct)
else:
t = time.strftime("%Y-%m-%d %H:%M:%S", ct)
s = "%s,%03d" % (t, record.msecs)
return s
【问题讨论】: