summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorareski <areski@gmail.com>2014-08-15 19:58:50 +0200
committerTim Graham <timograham@gmail.com>2014-08-15 15:17:48 -0400
commitee7289656c4aa18df91b3b18fff31cd010109de7 (patch)
tree26413c96864d4fe7e1e18a0068a9946d82966306 /docs
parent28d97533246fa1051e416ff772a40190b1f30e4d (diff)
[1.7.x] Fixed syntax highlighting and indentation in docs/topics/logging.txt.
Backport of 90b64db39c from master
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/logging.txt71
1 files changed, 41 insertions, 30 deletions
diff --git a/docs/topics/logging.txt b/docs/topics/logging.txt
index fe0c650bbf..1755a4f12b 100644
--- a/docs/topics/logging.txt
+++ b/docs/topics/logging.txt
@@ -481,13 +481,16 @@ a ``SuspiciousOperation`` will not be logged to the ``django.request`` logger,
but only to the ``django.security`` logger.
To silence a particular type of SuspiciousOperation, you can override that
-specific logger following this example::
+specific logger following this example:
- 'loggers': {
- 'django.security.DisallowedHost': {
- 'handlers': ['null'],
- 'propagate': False,
- },
+.. code-block:: python
+
+ 'loggers': {
+ 'django.security.DisallowedHost': {
+ 'handlers': ['null'],
+ 'propagate': False,
+ },
+ },
``django.db.backends.schema``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -520,7 +523,9 @@ Python logging module.
containing the full content of the debug Web page that would have been
produced if :setting:`DEBUG` were ``True``. To set this value in your
configuration, include it in the handler definition for
- ``django.utils.log.AdminEmailHandler``, like this::
+ ``django.utils.log.AdminEmailHandler``, like this:
+
+ .. code-block:: python
'handlers': {
'mail_admins': {
@@ -544,7 +549,9 @@ Python logging module.
By setting the ``email_backend`` argument of ``AdminEmailHandler``, the
:ref:`email backend <topic-email-backends>` that is being used by the
- handler can be overridden, like this::
+ handler can be overridden, like this:
+
+ .. code-block:: python
'handlers': {
'mail_admins': {
@@ -568,25 +575,27 @@ logging module.
.. class:: CallbackFilter(callback)
- 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 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.
+
+ For instance, to filter out :exc:`~django.http.UnreadablePostError`
+ (raised when a user cancels an upload) from the admin emails, you would
+ create a filter function::
- For instance, to filter out :exc:`~django.http.UnreadablePostError`
- (raised when a user cancels an upload) from the admin emails, you would
- create a filter function::
+ from django.http import UnreadablePostError
- from django.http import UnreadablePostError
+ def skip_unreadable_post(record):
+ if record.exc_info:
+ exc_type, exc_value = record.exc_info[:2]
+ if isinstance(exc_value, UnreadablePostError):
+ return False
+ return True
- def skip_unreadable_post(record):
- if record.exc_info:
- exc_type, exc_value = record.exc_info[:2]
- if isinstance(exc_value, UnreadablePostError):
- return False
- return True
+ and then add it to your logging config:
- and then add it to your logging config::
+ .. code-block:: python
'filters': {
'skip_unreadable_posts': {
@@ -604,13 +613,15 @@ logging module.
.. class:: RequireDebugFalse()
- This filter will only pass on records when settings.DEBUG is False.
+ 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``::
+ 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': {
+ .. code-block:: python
+
+ 'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse',
}
@@ -625,8 +636,8 @@ logging module.
.. class:: RequireDebugTrue()
- This filter is similar to :class:`RequireDebugFalse`, except that records are
- passed only when :setting:`DEBUG` is ``True``.
+ This filter is similar to :class:`RequireDebugFalse`, except that records are
+ passed only when :setting:`DEBUG` is ``True``.
.. _default-logging-configuration: