Created
May 7, 2014 01:11
-
-
Save mbylstra/e0f6d8bb1b8358d8d6cb to your computer and use it in GitHub Desktop.
log uncaught exceptions
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
import logging | |
logger = logging.getLogger('some_logger') | |
def log_uncaught_exceptions(*exc_info): | |
logger.critical('Unhandled Exception:', exc_info=exc_info) | |
sys.excepthook = log_uncaught_exceptions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
useful for django manage.py commands run from a cron