如何在python中使用不同时间戳的日志模块?

时间:2014-04-11 14:54:24

标签: python logging

我的位置距服务器位置3小时后,我希望在不更改服务器的情况下使我的本地时间与我的本地时间相同。设置?

1 个答案:

答案 0 :(得分:0)

答案是

import logging
import time

logging.basicConfig(format='%(asctime)s %(message)s')
logging.warning('server time')

logging.Formatter.converter = lambda self, current: time.localtime(current-3600*3)

logging.warning('time at your zone')

time.localtime是服务器时间。然后我给了偏见-3600 * 3(或者+是可能的)。