diff --git a/app/log.py b/app/log.py index b384f69..df8f3dc 100644 --- a/app/log.py +++ b/app/log.py @@ -76,3 +76,19 @@ syslog.setFormatter(syslog_formatter) # add the handlers to the log log.addHandler(stderr) log.addHandler(syslog) + + +def log_uncaught_exceptions(ex_cls, ex, tb): + + from helpers import send_mail + + print("\033[1;31;47m") + logging.critical(''.join(traceback.format_tb(tb))) + print("\033[1;37;40m") + stackprinter.show(style="darkbg2") + msg = stackprinter.format(ex) + send_mail(Config.ERRORS_TO, Config.ERRORS_FROM, + "Exception from musicmuster", msg) + + +sys.excepthook = log_uncaught_exceptions diff --git a/app/musicmuster.py b/app/musicmuster.py index a9eb945..ed912f5 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -1645,7 +1645,7 @@ if __name__ == "__main__": msg = stackprinter.format(exc) send_mail(Config.ERRORS_TO, Config.ERRORS_FROM, - "Exception from musicmuster", msg) + "Exception from musicmuster", msg) print("\033[1;31;47mUnhandled exception starts\033[1;37;40m") stackprinter.show(style="darkbg2")