From 15858083b3c3497a661cc6c6d4afbea43b6202a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20V=C3=B5sandi?= Date: Tue, 5 Apr 2016 15:30:50 +0300 Subject: [PATCH] Use UTC for log entries --- certidude/mysqllog.py | 3 ++- certidude/push.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/certidude/mysqllog.py b/certidude/mysqllog.py index e8d3083..514e2f9 100644 --- a/certidude/mysqllog.py +++ b/certidude/mysqllog.py @@ -1,6 +1,7 @@ import logging import time +from datetime import datetime from certidude.api.tag import RelationalMixin class LogHandler(logging.Handler, RelationalMixin): @@ -12,7 +13,7 @@ class LogHandler(logging.Handler, RelationalMixin): def emit(self, record): self.sql_execute("log_insert_entry.sql", - time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(record.created)), + datetime.utcfromtimestamp(record.created), record.name, record.levelno, record.levelname.lower(), diff --git a/certidude/push.py b/certidude/push.py index ae689a9..f84edd0 100644 --- a/certidude/push.py +++ b/certidude/push.py @@ -36,7 +36,7 @@ class PushLogHandler(logging.Handler): def emit(self, record): from certidude.push import publish publish("log-entry", dict( - created = datetime.fromtimestamp(record.created), + created = datetime.utcfromtimestamp(record.created), message = record.msg % record.args, severity = record.levelname.lower()))