summaryrefslogtreecommitdiffstats
path: root/Doc/library/logging.rst
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2010-09-17 12:45:26 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2010-09-17 12:45:26 (GMT)
commitac00799d61351d8f468af00d6194287bc37aad75 (patch)
tree9a8542289c37590d7221e401964c81aedd322d67 /Doc/library/logging.rst
parentc8c8c6968b076b61bd6873e1f92f8b918387ee6c (diff)
downloadcpython-ac00799d61351d8f468af00d6194287bc37aad75.zip
cpython-ac00799d61351d8f468af00d6194287bc37aad75.tar.gz
cpython-ac00799d61351d8f468af00d6194287bc37aad75.tar.bz2
Improved Filter documentation.
Diffstat (limited to 'Doc/library/logging.rst')
-rw-r--r--Doc/library/logging.rst14
1 files changed, 14 insertions, 0 deletions
diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst
index d9fcb23..7b579f1 100644
--- a/Doc/library/logging.rst
+++ b/Doc/library/logging.rst
@@ -1465,6 +1465,8 @@ When this script is run, the output should look something like this::
2008-01-18 14:49:54,033 d.e.f WARNING IP: 127.0.0.1 User: jim A message at WARNING level with 2 parameters
+.. _filters-contextual:
+
Using Filters to impart contextual information
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -2852,6 +2854,18 @@ etc.) This means that events which have been generated by descendant loggers
will not be filtered by a logger's filter setting, unless the filter has also
been applied to those descendant loggers.
+Other uses for filters
+^^^^^^^^^^^^^^^^^^^^^^
+
+Although filters are used primarily to filter records based on more
+sophisticated criteria than levels, they get to see every record which is
+processed by the handler or logger they're attached to: this can be useful if
+you want to do things like counting how many records were processed by a
+particular logger or handler, or adding, changing or removing attributes in
+the LogRecord being processed. Obviously changing the LogRecord needs to be
+done with some care, but it does allow the injection of contextual information
+into logs (see :ref:`filters-contextual`).
+
.. _log-record:
LogRecord Objects