Hi! I noticed vidcutter implements a custom log_uncaught_exceptions method in __main__.py:
def log_uncaught_exceptions(cls, exc, tb) -> None:
logging.critical(''.join(traceback.format_tb(tb)))
logging.critical('{0}: {1}'.format(cls, exc))
This is a solid approach — you are already using sys.excepthook properly. One small improvement I would suggest: the logged traceback does not include a timestamp, making it hard to correlate crash reports with specific events.
I maintain a small zero-dependency library called dttb that wraps this pattern cleanly:
import dttb
def on_crash(args: dttb.CallbackArgs) -> None:
logger.critical("Unhandled exception", exc_info=(args.exc_type, args.exc_value, args.exc_traceback))
dttb.apply(callback=on_crash)
Benefits over the current approach:
- ✅ Timestamps automatically prepended to each traceback
- ✅ Thread-safe — also hooks
threading.excepthook for child threads
- ✅ Zero dependencies, 2 lines
- ✅ Reduces boilerplate
This is just a suggestion — your current implementation is perfectly functional. Just thought it might be a useful improvement for users correlating crash logs.
GitHub: https://github.com/rocky-d/dttb | PyPI: pip install dttb
Hi! I noticed vidcutter implements a custom
log_uncaught_exceptionsmethod in__main__.py:This is a solid approach — you are already using
sys.excepthookproperly. One small improvement I would suggest: the logged traceback does not include a timestamp, making it hard to correlate crash reports with specific events.I maintain a small zero-dependency library called dttb that wraps this pattern cleanly:
Benefits over the current approach:
threading.excepthookfor child threadsThis is just a suggestion — your current implementation is perfectly functional. Just thought it might be a useful improvement for users correlating crash logs.
GitHub: https://github.com/rocky-d/dttb | PyPI:
pip install dttb