From 47ad76f513846a8501f84c057b28a146031859b6 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Thu, 8 Aug 2024 09:43:36 -0400 Subject: Show page in simulator (#3120) * add exception logging helpers * wip * show page and drop shadow from SVG * allow toggling page * add page icon * add dark mode icon * showpageshadow * refresh after background change (fix for macOS) * fix params sim background * try a native GraphicsBrush for windows * show page button in standalone simulator only and adapt shadow color * remove doubled line --------- Co-authored-by: Kaalleen --- lib/debug/debug.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/debug') diff --git a/lib/debug/debug.py b/lib/debug/debug.py index ab5132e4..d96dd36d 100644 --- a/lib/debug/debug.py +++ b/lib/debug/debug.py @@ -5,6 +5,7 @@ import atexit # to save svg file on exit import time # to measure time of code block, use time.monotonic() instead of time.time() +import traceback from datetime import datetime from contextlib import contextmanager # to measure time of with block @@ -246,6 +247,18 @@ class Debug(object): if self.enabled: self.raw_log("completed %s, duration = %s", label, time.monotonic() - start) + def log_exception(self): + if self.enabled: + self.raw_log(traceback.format_exc()) + + @contextmanager + def log_exceptions(self): + try: + yield + except Exception: + self.log_exception() + raise + # global debug object debug = Debug() -- cgit v1.2.3