-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
Enhancement: Timestamp on crash reports
Hi! Looking at the exception handler in main.py:
def handle_exception(exc_type, exc_value, exc_traceback):
print("Exception type:", exc_type)
print("Exception value:", exc_value)
trace_details = traceback.format_exception(exc_type, exc_value, exc_traceback)
trace_string = "".join(trace_details)
print("Exception traceback:", trace_string)
message = f"An error occurred!\n\n{exc_value}\n\n{trace_string}"
interface.display_error_message(message)
original_excepthook(exc_type, exc_value, exc_traceback)
sys.excepthook = handle_exceptionThe handler captures and displays exceptions well, but doesn't include when the crash happened — which is particularly valuable for a data collection tool like DuckTrack where you need to correlate crashes with session events.
Suggestion: dttb is a tiny package that patches sys.excepthook to add timestamps automatically:
import dttb
def my_callback(args: dttb.CallbackArgs) -> None:
# args.now — datetime of exception
# args.exc_type, args.exc_value, args.exc_traceback — standard exception info
trace_string = "".join(traceback.format_exception(args.exc_type, args.exc_value, args.exc_traceback))
message = f"[{args.now}] An error occurred!\n\n{args.exc_value}\n\n{trace_string}"
interface.display_error_message(message)
dttb.apply(callback=my_callback)This integrates cleanly with your existing handler pattern and makes the timestamp available both in the dialog and in any logs.
pip install dttb — https://github.com/rocky-d/dttb
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels