summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-09-08 07:33:16 (GMT)
committerGitHub <noreply@github.com>2022-09-08 07:33:16 (GMT)
commit6ee7a6b947c607ac79e5b66177405787dcaa8c06 (patch)
tree4049b5cae203102b079ea1a52f718ad84803caae
parente56116172ec1e6cab2da215034e2acc8433094db (diff)
downloadcpython-6ee7a6b947c607ac79e5b66177405787dcaa8c06.zip
cpython-6ee7a6b947c607ac79e5b66177405787dcaa8c06.tar.gz
cpython-6ee7a6b947c607ac79e5b66177405787dcaa8c06.tar.bz2
[3.10] gh-88287: Add BufferingFormatter documentation. (GH-96608) (GH-96674)
-rw-r--r--Doc/library/logging.rst29
1 files changed, 29 insertions, 0 deletions
diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst
index 824076f..6e83df8 100644
--- a/Doc/library/logging.rst
+++ b/Doc/library/logging.rst
@@ -652,6 +652,35 @@ The useful mapping keys in a :class:`LogRecord` are given in the section on
:func:`traceback.print_stack`, but with the last newline removed) as a
string. This default implementation just returns the input value.
+.. class:: BufferingFormatter(linefmt=None)
+
+ A base formatter class suitable for subclassing when you want to format a
+ number of records. You can pass a :class:`Formatter` instance which you want
+ to use to format each line (that corresponds to a single record). If not
+ specified, the default formatter (which just outputs the event message) is
+ used as the line formatter.
+
+ .. method:: formatHeader(records)
+
+ Return a header for a list of *records*. The base implementation just
+ returns the empty string. You will need to override this method if you
+ want specific behaviour, e.g. to show the count of records, a title or a
+ separator line.
+
+ .. method:: formatFooter(records)
+
+ Return a footer for a list of *records*. The base implementation just
+ returns the empty string. You will need to override this method if you
+ want specific behaviour, e.g. to show the count of records or a separator
+ line.
+
+ .. method:: format(records)
+
+ Return formatted text for a list of *records*. The base implementation
+ just returns the empty string if there are no records; otherwise, it
+ returns the concatenation of the header, each record formatted with the
+ line formatter, and the footer.
+
.. _filter:
Filter Objects