From cb0314da67458cf93baaa865b7846f826d522722 Mon Sep 17 00:00:00 2001 From: jesopo Date: Sun, 17 Feb 2019 14:15:40 +0000 Subject: Put a helper function in utils to do iso8601 formatting. change IRCServer's last-read setting to use it. --- src/Logging.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/Logging.py') diff --git a/src/Logging.py b/src/Logging.py index 879b8330..f82770fc 100644 --- a/src/Logging.py +++ b/src/Logging.py @@ -1,4 +1,5 @@ -import logging, logging.handlers, os, queue, sys, time, typing +import datetime, logging, logging.handlers, os, queue, sys, time, typing +from src import utils LEVELS = { "trace": logging.DEBUG-1, @@ -10,18 +11,9 @@ LEVELS = { } class BitBotFormatter(logging.Formatter): - converter = time.gmtime def formatTime(self, record, datefmt=None): - ct = self.converter(record.created) - if datefmt: - if "%f" in datefmt: - msec = "%03d" % record.msecs - datefmt = datefmt.replace("%f", msec) - s = time.strftime(datefmt, ct) - else: - t = time.strftime("%Y-%m-%d %H:%M:%S", ct) - s = "%s.%03d" % (t, record.msecs) - return s + datetime_obj = datetime.datetime.fromtimestamp(record.created) + return utils.iso8601_format(datetime_obj) class Log(object): def __init__(self, level: str, location: str): -- cgit v1.3.1-10-gc9f91