summaryrefslogtreecommitdiffstats
path: root/deluge/log.py
diff options
context:
space:
mode:
authorbendikro <bro.devel+deluge@gmail.com>2016-05-06 21:58:27 +0200
committerCalum Lind <calumlind+deluge@gmail.com>2016-05-09 13:57:54 +0100
commit1fb99601683a362f0e89c731d97a6ddf4455f8e6 (patch)
tree4f54b422f33e8c533ebe0bdf9508c3bd569c1d5b /deluge/log.py
parent919e41f55e486d5df69f030e6c506ea41acf14d7 (diff)
downloaddeluge-1fb99601683a362f0e89c731d97a6ddf4455f8e6.tar.gz
deluge-1fb99601683a362f0e89c731d97a6ddf4455f8e6.tar.bz2
deluge-1fb99601683a362f0e89c731d97a6ddf4455f8e6.zip
[Base] Updated fix for missing trace with new twisted logger
Includes a commented out test to replicate the issue.
Diffstat (limited to 'deluge/log.py')
-rw-r--r--deluge/log.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/deluge/log.py b/deluge/log.py
index eab4eaaa6..0732f84a0 100644
--- a/deluge/log.py
+++ b/deluge/log.py
@@ -155,25 +155,27 @@ def setup_logger(level="error", filename=None, filemode="w", logrotate=None):
twisted_logging = TwistedLoggingObserver()
twisted_logging.start()
- logging.getLogger("twisted").setLevel(level)
class TwistedLoggingObserver(PythonLoggingObserver):
+ """
+ Custom logging class to fix missing exception tracebacks in log output with new
+ twisted.logger module in twisted version >= 15.2.
+
+ Related twisted bug ticket: https://twistedmatrix.com/trac/ticket/7927
+
+ """
def __init__(self):
PythonLoggingObserver.__init__(self, loggerName='twisted')
def emit(self, event_dict):
log = logging.getLogger(__name__)
- try:
- fmt = "%(log_namespace)s "
- if event_dict.get("log_format", None):
- fmt += event_dict["log_format"]
- if event_dict["isError"] and "failure" in event_dict:
- fmt += "\n%(failure)s "
+ if "log_failure" in event_dict:
+ fmt = "%(log_namespace)s \n%(log_failure)s"
getattr(LoggingLoggerClass, event_dict["log_level"].name)(log, fmt % (event_dict))
- except (KeyError, AttributeError) as ex:
- log.error("ERROR when logging twisted error: '%s'", ex)
+ else:
+ PythonLoggingObserver.emit(self, event_dict)
def tweak_logging_levels():