Ticket #16288: debug_logging.diff
File debug_logging.diff, 2.5 KB (added by , 13 years ago) |
---|
-
django/conf/project_template/settings.py
125 125 126 126 # A sample logging configuration. The only tangible logging 127 127 # performed by this configuration is to send an email to 128 # the site admins on every HTTP 500 error .128 # the site admins on every HTTP 500 error when DEBUG=False. 129 129 # See http://docs.djangoproject.com/en/dev/topics/logging for 130 130 # more details on how to customize your logging configuration. 131 131 LOGGING = { 132 132 'version': 1, 133 133 'disable_existing_loggers': False, 134 'filters': { 135 'require_debug_false': { 136 '()': 'django.utils.log.DebugFalseFilter' 137 } 138 }, 134 139 'handlers': { 135 140 'mail_admins': { 136 141 'level': 'ERROR', 142 'filters': ['require_debug_false'], 137 143 'class': 'django.utils.log.AdminEmailHandler' 138 144 } 139 145 }, -
django/core/handlers/base.py
198 198 if settings.DEBUG_PROPAGATE_EXCEPTIONS: 199 199 raise 200 200 201 if settings.DEBUG:202 from django.views import debug203 return debug.technical_500_response(request, *exc_info)204 205 201 logger.error('Internal Server Error: %s' % request.path, 206 202 exc_info=exc_info, 207 203 extra={ … … 210 206 } 211 207 ) 212 208 209 if settings.DEBUG: 210 from django.views import debug 211 return debug.technical_500_response(request, *exc_info) 212 213 213 # If Http500 handler is not installed, re-raise last exception 214 214 if resolver.urlconf_module is None: 215 215 raise exc_info[1], None, exc_info[2] -
django/utils/log.py
70 70 reporter = ExceptionReporter(request, is_email=True, *exc_info) 71 71 html_message = self.include_html and reporter.get_traceback_html() or None 72 72 mail.mail_admins(subject, message, fail_silently=True, html_message=html_message) 73 74 75 class DebugFalseFilter(logging.Filter): 76 """A filter that disables a logger or handler when debug mode is enabled.""" 77 def filter(self, record): 78 if settings.DEBUG: 79 return 0 80 return 1