Skip to content

Instantly share code, notes, and snippets.

@mbylstra
Created May 7, 2014 01:11
Show Gist options
  • Save mbylstra/e0f6d8bb1b8358d8d6cb to your computer and use it in GitHub Desktop.
Save mbylstra/e0f6d8bb1b8358d8d6cb to your computer and use it in GitHub Desktop.
log uncaught exceptions
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
@mbylstra
Copy link
Author

mbylstra commented May 7, 2014

useful for django manage.py commands run from a cron

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment