Much improved stderr reporting on exceptions
This commit is contained in:
parent
45a22c47d0
commit
afc3014b18
10
app/log.py
10
app/log.py
@ -6,7 +6,7 @@ import logging.handlers
|
||||
import os
|
||||
import stackprinter # type: ignore
|
||||
import sys
|
||||
import traceback
|
||||
from traceback import print_exception
|
||||
|
||||
from config import Config
|
||||
|
||||
@ -48,19 +48,19 @@ syslog.setFormatter(syslog_fmt)
|
||||
log.addHandler(syslog)
|
||||
|
||||
|
||||
def log_uncaught_exceptions(_ex_cls, ex, tb):
|
||||
def log_uncaught_exceptions(type_, value, traceback):
|
||||
from helpers import send_mail
|
||||
|
||||
print("\033[1;31;47m")
|
||||
logging.critical("".join(traceback.format_tb(tb)))
|
||||
print_exception(type_, value, traceback)
|
||||
print("\033[1;37;40m")
|
||||
print(
|
||||
stackprinter.format(
|
||||
ex, suppressed_paths=["/pypoetry/virtualenvs/"], style="darkbg"
|
||||
value, suppressed_paths=["/pypoetry/virtualenvs/"], style="darkbg"
|
||||
)
|
||||
)
|
||||
if os.environ["MM_ENV"] == "PRODUCTION":
|
||||
msg = stackprinter.format(ex)
|
||||
msg = stackprinter.format(value)
|
||||
send_mail(
|
||||
Config.ERRORS_TO, Config.ERRORS_FROM, "Exception from musicmuster", msg
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user