From 7d54bd6ad06b39fe716392ebda69f9a087104d1d Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 30 Oct 2018 18:03:44 +0000 Subject: [PATCH] Move setting BitBotFormatter's converter (to time.gmtime) to class definition as it's not technically correct to overwrite a funcion on an existing object --- src/Logging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Logging.py b/src/Logging.py index d5c42e56..a4af69f7 100644 --- a/src/Logging.py +++ b/src/Logging.py @@ -10,6 +10,7 @@ LEVELS = { } class BitBotFormatter(logging.Formatter): + converter = time.gmtime def formatTime(self, record, datefmt=None): ct = self.converter(record.created) if datefmt: @@ -36,7 +37,6 @@ class Log(object): formatter = BitBotFormatter( "%(asctime)s [%(levelname)s] %(message)s", "%Y-%m-%dT%H:%M:%S.%fZ") - formatter.converter = time.gmtime stdout_handler = logging.StreamHandler(sys.stdout) stdout_handler.setLevel(stdout_level)