Last active
December 13, 2015 17:58
-
-
Save mgedmin/4952018 to your computer and use it in GitHub Desktop.
Today's best Python code (from ZConfig/components/logger/tests/test_logger.py)
This file contains hidden or 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
class CustomFormatter(logging.Formatter): | |
def formatException(self, ei): | |
"""Format and return the exception information as a string. | |
This adds helpful advice to the end of the traceback. | |
""" | |
import traceback | |
sio = StringIO.StringIO() | |
traceback.print_exception(ei[0], ei[1], ei[2], file=sio) | |
return sio.getvalue() + "... Don't panic!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
or simply