summaryrefslogtreecommitdiffstats
path: root/deluge
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2021-07-25 11:16:03 +0100
committerCalum Lind <calumlind+deluge@gmail.com>2021-07-25 13:28:18 +0100
commitf16afc59ba84d6535ed90d90119cc4e7012a504d (patch)
tree5867b7450bf26257b314be338e2745221b767021 /deluge
parente5388048a95df6ba38d406043ec068928bd3dbcf (diff)
downloaddeluge-f16afc59ba84d6535ed90d90119cc4e7012a504d.tar.gz
deluge-f16afc59ba84d6535ed90d90119cc4e7012a504d.tar.bz2
deluge-f16afc59ba84d6535ed90d90119cc4e7012a504d.zip
Ignore TypeError with custom Twisted logging
The modification of Python logging _findCaller args in Python 3.8 raises TypeError in our custom Twisted Logger with Twisted <= 19 versions. The actual issue for the custom logger was fixed in 18.9 so added a version check to avoid usage. Refs: - https://twistedmatrix.com/trac/ticket/7927 - https://github.com/twisted/twisted/commit/6b894744e4d2439c1a4436d1e0e0b2a6cdff68e4
Diffstat (limited to 'deluge')
-rw-r--r--deluge/log.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/deluge/log.py b/deluge/log.py
index bf4f3c2d7..fa83091d1 100644
--- a/deluge/log.py
+++ b/deluge/log.py
@@ -17,6 +17,8 @@ import logging.handlers
import os
import sys
+from incremental import Version
+from twisted import version as twisted_version
from twisted.internet import defer
from twisted.python.log import PythonLoggingObserver
@@ -180,7 +182,8 @@ def setup_logger(
root_logger.addHandler(handler)
root_logger.setLevel(level)
- if twisted_observer:
+ # Issue fixed in Twisted 18.9.0 https://twistedmatrix.com/trac/ticket/7927
+ if twisted_observer and twisted_version < Version('Twisted', 18, 9, 0):
twisted_logging = TwistedLoggingObserver()
twisted_logging.start()
@@ -204,8 +207,13 @@ class TwistedLoggingObserver(PythonLoggingObserver):
getattr(LoggingLoggerClass, event_dict['log_level'].name)(
log, fmt % (event_dict)
)
- else:
+ return
+
+ try:
PythonLoggingObserver.emit(self, event_dict)
+ except TypeError:
+ # Ignore logging args problem with Python 3.8 and Twisted <= 19
+ pass
def tweak_logging_levels():