aboutsummaryrefslogtreecommitdiff
path: root/src/Logging.py
diff options
context:
space:
mode:
authorGravatar jesopo2019-01-16 12:03:56 +0000
committerGravatar jesopo2019-01-16 12:03:56 +0000
commit470f85b009962d10210a13f9751a8a58bb77d809 (patch)
treea7ee29f4239cbab61b22e9aaca8e0c264eddbfcf /src/Logging.py
parentSupport removal of modes without args that we don't know about in a way that (diff)
signature
Pushing logging on to another thread was a ridiculous idea. it means CRITICAL
logs are in a race condition to write to file before the main thread exits.
Diffstat (limited to 'src/Logging.py')
-rw-r--r--src/Logging.py18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/Logging.py b/src/Logging.py
index 60c008a6..8de57d83 100644
--- a/src/Logging.py
+++ b/src/Logging.py
@@ -1,4 +1,4 @@
-import logging, logging.handlers, os, queue, sys, threading, time, typing
+import logging, logging.handlers, os, queue, sys, time, typing
LEVELS = {
"trace": logging.DEBUG-1,
@@ -54,16 +54,6 @@ class Log(object):
warn_handler.setFormatter(formatter)
self.logger.addHandler(warn_handler)
- self._queue = queue.Queue() # type: queue.Queue[typing.Tuple[str, typing.List, int, typing.Dict]]
- self._thread = threading.Thread(target=self._loop)
- self._thread.daemon = True
- self._thread.start()
-
- def _loop(self):
- while True:
- message, params, level, kwargs = self._queue.get(block=True)
- self.logger.log(level, message, *params, **kwargs)
-
def trace(self, message: str, params: typing.List, **kwargs):
self._log(message, params, LEVELS["trace"], kwargs)
def debug(self, message: str, params: typing.List, **kwargs):
@@ -77,8 +67,4 @@ class Log(object):
def critical(self, message: str, params: typing.List, **kwargs):
self._log(message, params, logging.CRITICAL, kwargs)
def _log(self, message: str, params: typing.List, level: int, kwargs: dict):
- if kwargs.get("exc_info") == True:
- # because we're doing the actual logging on another thread,
- # we need to catch actual exception information here.
- kwargs["exc_info"] = sys.exc_info()
- self._queue.put((message, params, level, kwargs))
+ self.logger.log(level, message, *params, **kwargs)