1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #16568 -- Added RequireDebugFalse filter to prevent sending 500 error emails when DEBUG is True in projects with no explicit LOGGING setting. Thanks to Andreas Pelme for report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16840 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Carl Meyer
2011-09-16 16:41:38 +00:00
parent f9dad46d36
commit 343004c4de
7 changed files with 35 additions and 30 deletions

View File

@@ -593,8 +593,7 @@ to :class:`django.utils.log.AdminEmailHandler` to prevent admin error emails in
'filters': {
'require_debug_false': {
'()': 'django.utils.log.CallbackFilter',
'callback': lambda r: not DEBUG
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {

View File

@@ -504,8 +504,8 @@ Python logging module.
Filters
-------
Django provides one log filter in addition to those provided by the
Python logging module.
Django provides two log filters in addition to those provided by the Python
logging module.
.. class:: CallbackFilter(callback)
@@ -516,14 +516,19 @@ Python logging module.
through the filter. Handling of that record will not proceed if the callback
returns False.
.. class:: RequireDebugFalse()
.. versionadded:: 1.4
This filter will only pass on records when settings.DEBUG is 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
'()': 'django.utils.log.RequireDebugFalse',
}
},
'handlers': {