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
相關文章
相關標籤/搜索