OpenERP 日志时间与系统时间时区不同。

查看log的时候看到log时间与系统时间相差了八个小时。3d

调试了一下,能够这样修改:调试

修改文件 netsvc.pycode

 重写 formatTime 方法 (我把相差时间直接写死了)orm

 

class DBFormatter(logging.Formatter):
    def format(self, record):
        record.pid = os.getpid()
        record.dbname = getattr(threading.currentThread(), 'dbname', '?')
        return logging.Formatter.format(self, record)
    def formatTime(self, record, datefmt=None):
        now = datetime.datetime.now()+datetime.timedelta(hours=8)
        ct = time.localtime(time.mktime(now.timetuple()))

        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
相关文章
相关标签/搜索