Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.10] gh-88287: Add BufferingFormatter documentation. (GH-96608) (GH-96674) #96674

Merged
merged 1 commit into from
Sep 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Doc/library/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down