Created
February 16, 2013 20:18
-
-
Save spidaman/4968556 to your computer and use it in GitHub Desktop.
Logging stacktraces from python exceptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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