Ticket #3707: log_errs.patch
File log_errs.patch, 1.5 KB (added by , 18 years ago) |
---|
-
django/core/handlers/base.py
113 113 # Get the exception info now, in case another exception is thrown later. 114 114 exc_info = sys.exc_info() 115 115 receivers = dispatcher.send(signal=signals.got_request_exception) 116 # When DEBUG is False, send an error message to the admins .116 # When DEBUG is False, send an error message to the admins/log to file. 117 117 subject = 'Error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS and 'internal' or 'EXTERNAL'), request.path) 118 118 try: 119 119 request_repr = repr(request) … … 121 121 request_repr = "Request repr() unavailable" 122 122 message = "%s\n\n%s" % (self._get_traceback(exc_info), request_repr) 123 123 mail_admins(subject, message, fail_silently=True) 124 if settings.ERROR_LOG: 125 log = open(settings.ERROR_LOG, 'a') 126 log.writelines((subject,message)) 127 log.close() 124 128 # Return an HttpResponse that displays a friendly error message. 125 129 callback, param_dict = resolver.resolve500() 126 130 return callback(request, **param_dict)