Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/helpermodules/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,20 @@ def mb_to_bytes(megabytes: int) -> int:
logging.getLogger("websockets").setLevel(logging.WARNING)

def threading_excepthook(args):
logging.getLogger(__name__).error("Uncaught exception in threading.excepthook:", exc_info=(
args.exc_type, args.exc_value, args.exc_traceback))
with open(RAMDISK_PATH+"thread_errors.log", "a") as f:
f.write("Uncaught exception in thread:\n")
f.write(f"Type: {args.exc_type}\n")
f.write(f"Value: {args.exc_value}\n")
import traceback
traceback.print_tb(args.exc_traceback, file=f)
threading.excepthook = threading_excepthook

def handle_unhandled_exception(exc_type, exc_value, exc_traceback):
logging.getLogger(__name__).error("Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback))
with open(RAMDISK_PATH+"thread_errors.log", "a") as f:
f.write("Uncaught exception:\n")
f.write(f"Type: {exc_type}\n")
f.write(f"Value: {exc_value}\n")
f.write(f"Traceback:{exc_traceback}\n")
sys.excepthook = handle_unhandled_exception


Expand Down
1 change: 1 addition & 0 deletions packages/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def handler5Min(self):
def handler_midnight(self):
try:
save_log(LogType.MONTHLY)
Path(Path(__file__).resolve().parents[1]/"ramdisk"/"thread_errors.log").unlink(missing_ok=True)
except KeyboardInterrupt:
log.critical("Ausführung durch exit_after gestoppt: "+traceback.format_exc())
except Exception:
Expand Down