Fixed #16288 -- Enabled django.request exception logger regardless of DEBUG setting.

Thanks Matt Bennett for report and draft patch; Vinay Sajip and Russell Keith-Magee for review.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16444 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Carl Meyer 2011-06-22 06:01:44 +00:00
parent 9eb2afddfa
commit 43503b093a
12 changed files with 285 additions and 5 deletions

View file

@ -501,3 +501,37 @@ Python logging module.
:ref:`Filtering error reports<filtering-error-reports>`.
.. _django-sentry: http://pypi.python.org/pypi/django-sentry
Filters
-------
Django provides one log filter in addition to those provided by the
Python logging module.
.. class:: CallbackFilter(callback)
.. versionadded:: 1.4
This filter accepts a callback function (which should accept a single
argument, the record to be logged), and calls it for each record that passes
through the filter. Handling of that record will not proceed if the callback
returns False.
This filter is used as follows in the default :setting:`LOGGING`
configuration to ensure that the :class:`AdminEmailHandler` only sends error
emails to admins when :setting:`DEBUG` is `False`::
'filters': {
'require_debug_false': {
'()': 'django.utils.log.CallbackFilter',
'callback': lambda r: not DEBUG
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},