summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2011-06-22 06:01:44 +0000
committerCarl Meyer <carl@oddbird.net>2011-06-22 06:01:44 +0000
commit43503b093a35ca4707c16d865f10929960bfa0b8 (patch)
tree338ec327f54ee0590840e5164c3bbcb817ddda10 /docs
parent9eb2afddfa0165d69f3e506122c2aa2b68618591 (diff)
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
Diffstat (limited to 'docs')
-rw-r--r--docs/internals/deprecation.txt5
-rw-r--r--docs/releases/1.4.txt41
-rw-r--r--docs/topics/logging.txt34
3 files changed, 80 insertions, 0 deletions
diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt
index 131f813f83..cd65a89e22 100644
--- a/docs/internals/deprecation.txt
+++ b/docs/internals/deprecation.txt
@@ -210,6 +210,11 @@ their deprecation, as per the :ref:`Django deprecation policy
* Legacy ways of calling
:func:`~django.views.decorators.cache.cache_page` will be removed.
+ * The backward-compatibility shim to automatically add a debug-false
+ filter to the ``'mail_admins'`` logging handler will be removed. The
+ :setting:`LOGGING` setting should include this filter explicitly if
+ it is desired.
+
* 2.0
* ``django.views.defaults.shortcut()``. This function has been moved
to ``django.contrib.contenttypes.views.shortcut()`` as part of the
diff --git a/docs/releases/1.4.txt b/docs/releases/1.4.txt
index 7cc3fb1bc2..0635ecefee 100644
--- a/docs/releases/1.4.txt
+++ b/docs/releases/1.4.txt
@@ -387,3 +387,44 @@ releases 8.0 and 8.1 was near (November 2010.)
Django 1.4 takes that policy further and sets 8.2 as the minimum PostgreSQL
version it officially supports.
+
+Request exceptions are now always logged
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+When :doc:`logging support </topics/logging/>` was added to Django in 1.3, the
+admin error email support was moved into the
+:class:`django.utils.log.AdminEmailHandler`, attached to the
+``'django.request'`` logger. In order to maintain the established behavior of
+error emails, the ``'django.request'`` logger was called only when
+:setting:`DEBUG` was `False`.
+
+To increase the flexibility of request-error logging, the ``'django.request'``
+logger is now called regardless of the value of :setting:`DEBUG`, and the
+default settings file for new projects now includes a separate filter attached
+to :class:`django.utils.log.AdminEmailHandler` to prevent admin error emails in
+`DEBUG` mode::
+
+ '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'
+ }
+ },
+
+If your project was created prior to this change, your :setting:`LOGGING`
+setting will not include this new filter. In order to maintain
+backwards-compatibility, Django will detect that your ``'mail_admins'`` handler
+configuration includes no ``'filters'`` section, and will automatically add
+this filter for you and issue a pending-deprecation warning. This will become a
+deprecation warning in Django 1.5, and in Django 1.6 the
+backwards-compatibility shim will be removed entirely.
+
+The existence of any ``'filters'`` key under the ``'mail_admins'`` handler will
+disable this backward-compatibility shim and deprecation warning.
diff --git a/docs/topics/logging.txt b/docs/topics/logging.txt
index 06050af899..9137038214 100644
--- a/docs/topics/logging.txt
+++ b/docs/topics/logging.txt
@@ -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'
+ }
+ },