Last active
August 29, 2015 14:16
-
-
Save kracekumar/46ac62b2cffff12c72e0 to your computer and use it in GitHub Desktop.
django print exception to console
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
# -*- 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