Skip to content
Merged
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
12 changes: 9 additions & 3 deletions packages/helpermodules/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,15 @@ def mb_to_bytes(megabytes: int) -> int:
logging.getLogger("uModbus").setLevel(logging.WARNING)
logging.getLogger("websockets").setLevel(logging.WARNING)

thread_errors_path = Path(Path(__file__).resolve().parents[2]/"ramdisk"/"thread_errors.log")
thread_errors_path = Path(RAMDISK_PATH+"thread_errors.log")
with thread_errors_path.open("w") as f:
f.write("")

def threading_excepthook(args):
with open(RAMDISK_PATH+"thread_errors.log", "a") as f:
if thread_errors_path.exists() and thread_errors_path.stat().st_size > 10_000:
with thread_errors_path.open("w") as f:
f.write("")
with open(thread_errors_path, "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")
Expand All @@ -348,7 +351,10 @@ def threading_excepthook(args):
threading.excepthook = threading_excepthook

def handle_unhandled_exception(exc_type, exc_value, exc_traceback):
with open(RAMDISK_PATH+"thread_errors.log", "a") as f:
if thread_errors_path.exists() and thread_errors_path.stat().st_size > 10_000:
with thread_errors_path.open("w") as f:
f.write("")
with open(thread_errors_path, "a") as f:
f.write("Uncaught exception:\n")
f.write(f"Type: {exc_type}\n")
f.write(f"Value: {exc_value}\n")
Expand Down