Better stackprinter handling

This commit is contained in:
Keith Edmunds 2022-12-19 21:07:03 +00:00
parent 0d4b306fc4
commit 78a9103490
2 changed files with 17 additions and 1 deletions

View File

@ -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

View File

@ -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")