diff --git a/resources/lib/helper/loghandler.py b/resources/lib/helper/loghandler.py index 49b71940..5890bb7a 100644 --- a/resources/lib/helper/loghandler.py +++ b/resources/lib/helper/loghandler.py @@ -7,6 +7,7 @@ from __future__ import print_function import os import logging +import traceback import xbmc import xbmcaddon @@ -119,6 +120,22 @@ class MyFormatter(logging.Formatter): return result + def formatException(self, exc_info): + _pluginpath_real = os.path.realpath(__pluginpath__) + res = [] + + for o in traceback.format_exception(*exc_info): + if o.startswith(' File "'): + # If this split can't handle your file names, you should seriously consider renaming your files. + fn = o.split(' File "', 2)[1].split('", line ', 1)[0] + rfn = os.path.realpath(fn) + if rfn.startswith(_pluginpath_real): + o = o.replace(fn, os.path.relpath(rfn, _pluginpath_real)) + + res.append(o) + + return ''.join(res) + def _gen_rel_path(self, record): if record.pathname: record.relpath = os.path.relpath(record.pathname, __pluginpath__)