Fixed syntax highlighting and indentation in docs/topics/logging.txt.
This commit is contained in:
parent
7ca665c5f5
commit
90b64db39c
|
@ -481,13 +481,16 @@ a ``SuspiciousOperation`` will not be logged to the ``django.request`` logger,
|
||||||
but only to the ``django.security`` logger.
|
but only to the ``django.security`` logger.
|
||||||
|
|
||||||
To silence a particular type of SuspiciousOperation, you can override that
|
To silence a particular type of SuspiciousOperation, you can override that
|
||||||
specific logger following this example::
|
specific logger following this example:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
'loggers': {
|
'loggers': {
|
||||||
'django.security.DisallowedHost': {
|
'django.security.DisallowedHost': {
|
||||||
'handlers': ['null'],
|
'handlers': ['null'],
|
||||||
'propagate': False,
|
'propagate': False,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
|
||||||
``django.db.backends.schema``
|
``django.db.backends.schema``
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -520,7 +523,9 @@ Python logging module.
|
||||||
containing the full content of the debug Web page that would have been
|
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
|
produced if :setting:`DEBUG` were ``True``. To set this value in your
|
||||||
configuration, include it in the handler definition for
|
configuration, include it in the handler definition for
|
||||||
``django.utils.log.AdminEmailHandler``, like this::
|
``django.utils.log.AdminEmailHandler``, like this:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
'handlers': {
|
'handlers': {
|
||||||
'mail_admins': {
|
'mail_admins': {
|
||||||
|
@ -542,7 +547,9 @@ Python logging module.
|
||||||
|
|
||||||
By setting the ``email_backend`` argument of ``AdminEmailHandler``, the
|
By setting the ``email_backend`` argument of ``AdminEmailHandler``, the
|
||||||
:ref:`email backend <topic-email-backends>` that is being used by 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': {
|
'handlers': {
|
||||||
'mail_admins': {
|
'mail_admins': {
|
||||||
|
@ -567,9 +574,9 @@ logging module.
|
||||||
.. class:: CallbackFilter(callback)
|
.. class:: CallbackFilter(callback)
|
||||||
|
|
||||||
This filter accepts a callback function (which should accept a single
|
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
|
argument, the record to be logged), and calls it for each record that
|
||||||
through the filter. Handling of that record will not proceed if the callback
|
passes through the filter. Handling of that record will not proceed if the
|
||||||
returns False.
|
callback returns False.
|
||||||
|
|
||||||
For instance, to filter out :exc:`~django.http.UnreadablePostError`
|
For instance, to filter out :exc:`~django.http.UnreadablePostError`
|
||||||
(raised when a user cancels an upload) from the admin emails, you would
|
(raised when a user cancels an upload) from the admin emails, you would
|
||||||
|
@ -584,7 +591,9 @@ logging module.
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
and then add it to your logging config::
|
and then add it to your logging config:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
'filters': {
|
'filters': {
|
||||||
'skip_unreadable_posts': {
|
'skip_unreadable_posts': {
|
||||||
|
@ -605,8 +614,10 @@ logging module.
|
||||||
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`
|
This filter is used as follows in the default :setting:`LOGGING`
|
||||||
configuration to ensure that the :class:`AdminEmailHandler` only sends error
|
configuration to ensure that the :class:`AdminEmailHandler` only sends
|
||||||
emails to admins when :setting:`DEBUG` is ``False``::
|
error emails to admins when :setting:`DEBUG` is ``False``:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
'filters': {
|
'filters': {
|
||||||
'require_debug_false': {
|
'require_debug_false': {
|
||||||
|
|
Loading…
Reference in New Issue