Skip to content

Instantly share code, notes, and snippets.

@kracekumar
Last active August 29, 2015 14:16
Show Gist options
  • Save kracekumar/46ac62b2cffff12c72e0 to your computer and use it in GitHub Desktop.
Save kracekumar/46ac62b2cffff12c72e0 to your computer and use it in GitHub Desktop.
django print exception to console
# -*- coding: utf-8 -*-
class ConsoleExceptionLoggerMiddleware(object):
def process_exception(self, request, exception):
import traceback
import sys
exc_info = sys.exc_info()
print("-" * 30 + "Exception" + "-" * 50)
print('\n'.join(traceback.format_exception(*(exc_info or sys.exc_info()))))
print("-" * 88)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment