Better stackprinter handling
This commit is contained in:
parent
0d4b306fc4
commit
78a9103490
16
app/log.py
16
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
|
||||
|
||||
@ -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")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user