Fix logging in non-debug mode

This commit is contained in:
shortcutme 2019-11-07 02:47:45 +01:00
parent d569d9488a
commit f9b62564ca
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 7 additions and 3 deletions

View file

@ -26,14 +26,18 @@ def formatException(err=None, format="text"):
import traceback import traceback
if type(err) == Notify: if type(err) == Notify:
return err return err
elif type(err) == tuple and err[0] is not None: # Passed trackeback info elif type(err) == tuple and err and err[0] is not None: # Passed trackeback info
exc_type, exc_obj, exc_tb = err exc_type, exc_obj, exc_tb = err
err = None err = None
else: # No trackeback info passed, get latest else: # No trackeback info passed, get latest
exc_type, exc_obj, exc_tb = sys.exc_info() exc_type, exc_obj, exc_tb = sys.exc_info()
if not err: if not err:
err = exc_obj.message if hasattr(err, "message"):
err = exc_obj.message
else:
err = exc_obj
tb = [] tb = []
for frame in traceback.extract_tb(exc_tb): for frame in traceback.extract_tb(exc_tb):
path, line, function, text = frame path, line, function, text = frame

View file

@ -50,7 +50,7 @@ def handleErrorNotify(*args, **kwargs):
if err.__name__ == "KeyboardInterrupt": if err.__name__ == "KeyboardInterrupt":
shutdown("Keyboard interrupt") shutdown("Keyboard interrupt")
elif err.__name__ != "Notify": elif err.__name__ != "Notify":
logging.error("Unhandled exception: %s" % [args]) logging.error("Unhandled exception 3: %s" % Debug.formatException())
sys.__excepthook__(*args, **kwargs) sys.__excepthook__(*args, **kwargs)