Ticket #3707: log_errs.patch

File log_errs.patch, 1.5 KB (added by yary h <not.com@…>, 18 years ago)

simple implementation

  • django/core/handlers/base.py

     
    113113                # Get the exception info now, in case another exception is thrown later.
    114114                exc_info = sys.exc_info()
    115115                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.
    117117                subject = 'Error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS and 'internal' or 'EXTERNAL'), request.path)
    118118                try:
    119119                    request_repr = repr(request)
     
    121121                    request_repr = "Request repr() unavailable"
    122122                message = "%s\n\n%s" % (self._get_traceback(exc_info), request_repr)
    123123                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()
    124128                # Return an HttpResponse that displays a friendly error message.
    125129                callback, param_dict = resolver.resolve500()
    126130                return callback(request, **param_dict)
Back to Top