Skip to content

Instantly share code, notes, and snippets.

@spidaman
Created February 16, 2013 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spidaman/4968556 to your computer and use it in GitHub Desktop.
Save spidaman/4968556 to your computer and use it in GitHub Desktop.
Logging stacktraces from python exceptions
import logging, sys, traceback
from stuff import DoStuff
try:
DoStuff.shit_can_happen()
except ShitHappens, e:
exc_type, exc_value, exc_traceback = sys.exc_info()
stacktrace = "".join(traceback.format_exception(exc_type, exc_value, exc_traceback))
logger.debug(stacktrace)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment