Skip to content

Instantly share code, notes, and snippets.

@alanbriolat
Created June 9, 2014 14:15
Show Gist options
  • Select an option

  • Save alanbriolat/0ced3d4f9caad67a81a5 to your computer and use it in GitHub Desktop.

Select an option

Save alanbriolat/0ced3d4f9caad67a81a5 to your computer and use it in GitHub Desktop.
Log unhandled Python exceptions with logging.critical(...).
import traceback
import sys
def excepthook(type, value, tb):
for part in traceback.format_exception(type, value, tb):
for line in part.splitlines():
logging.critical(line)
sys.excepthook = excepthook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment