diff --git a/excepthook.py b/excepthook.py index 1921314b74..27631b4f7e 100644 --- a/excepthook.py +++ b/excepthook.py @@ -11,10 +11,12 @@ def uncaught_exception(exctype, value, tb): delta = now - UtcDate.startup_utc_date seconds = delta.total_seconds() tr = os.linesep.join(traceback.format_tb(tb)) - print(tr) + exception_only = ''.join(traceback.format_exception_only(exctype, value)).strip() + logged_msg = exception_only + os.linesep + str(now) + " UTC" + os.linesep + tr + os.linesep + os.linesep + print(logged_msg) with open("errorLogs.txt", "a") as f: - f.write(str(now) + " UTC" + os.linesep + tr + os.linesep + os.linesep) - if seconds < 180 : + f.write(logged_msg) + if seconds < 180: os._exit(4) else: os._exit(1) diff --git a/ws.py b/ws.py index da11b165d2..794cfb4ef5 100644 --- a/ws.py +++ b/ws.py @@ -71,14 +71,15 @@ def restart_automatically(time_in_seconds): delta = now - UtcDate.startup_utc_date seconds = delta.total_seconds() tr = traceback.format_exc() - print(tr) + exception_only = ''.join(traceback.format_exception_only(type(e), e)).strip() + logged_msg = str(now) + " UTC" + os.linesep + exception_only + os.linesep + tr + os.linesep + os.linesep + print(logged_msg) with open("errorLogs.txt", "a") as f: - f.write(str(now) + " UTC" + os.linesep + tr + os.linesep + os.linesep) + f.write(logged_msg) if seconds < 180: os._exit(4) ws = websocket.create_connection("ws://qa.sockets.stackexchange.com/") ws.send("155-questions-active") - exception_only = ''.join(traceback.format_exception_only(type(e), e)).strip() GlobalVars.charcoal_hq.send_message("Recovered from `" + exception_only + "`") now = datetime.utcnow()