Python Recipe - Log All Exceptions
import logging
import sys
def handle_unhandled_exception(exc_type, exc_value, exc_traceback):
if issubclass(exc_type, KeyboardInterrupt):
# Let KeyboardInterrupt pass through for normal exits
sys.__excepthook__(exc_type, exc_value, exc_traceback)