Overwriting logging.Formatter._fmt seems to

no longer work in Python 3
This commit is contained in:
Odd Stråbø 2020-04-19 04:37:58 +02:00
parent 795dfd38df
commit 6c5ac6292d

View file

@ -61,9 +61,6 @@ class LogHandler(logging.StreamHandler):
for token in self.sensitive['Token']:
string = string.replace(token or "{token}", "{jellyfin-token}")
try:
xbmc.log(string, level=xbmc.LOGNOTICE)
except UnicodeEncodeError:
xbmc.log(string, level=xbmc.LOGNOTICE)
@classmethod
@ -85,27 +82,15 @@ class LogHandler(logging.StreamHandler):
class MyFormatter(logging.Formatter):
def __init__(self, fmt="%(name)s -> %(message)s"):
def __init__(self, fmt='%(name)s -> %(levelname)s::%(relpath)s:%(lineno)s %(message)s'):
logging.Formatter.__init__(self, fmt)
def format(self, record):
# Save the original format configured by the user
# when the logger formatter was instantiated
format_orig = self._fmt
self._gen_rel_path(record)
# Replace the original format with one customized by logging level
self._fmt = '%(name)s -> %(levelname)s::%(relpath)s:%(lineno)s %(message)s'
# Call the original formatter class to do the grunt work
result = logging.Formatter.format(self, record)
# Restore the original format configured by the user
self._fmt = format_orig
return result
def formatException(self, exc_info):