aboutsummaryrefslogtreecommitdiff
path: root/src/Logging.py
diff options
context:
space:
mode:
authorGravatar jesopo2019-02-17 14:15:40 +0000
committerGravatar jesopo2019-02-17 14:15:40 +0000
commitcb0314da67458cf93baaa865b7846f826d522722 (patch)
tree6c79fc60666de1d4486771700cf4bf9bad6e51dd /src/Logging.py
parentLink to a better resource that explains how to get custom search api key and ID (diff)
signature
Put a helper function in utils to do iso8601 formatting. change IRCServer's
last-read setting to use it.
Diffstat (limited to 'src/Logging.py')
-rw-r--r--src/Logging.py16
1 files changed, 4 insertions, 12 deletions
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):