Commit 84de34e3 authored by Vinay Sajip's avatar Vinay Sajip Committed by GitHub

bpo-32934: Clarified meaning of 'capacity' for BufferingHandler and MemoryHandler. (GH-14498)

parent 4a2edc34
...@@ -2266,9 +2266,9 @@ The script just arranges to decorate ``foo`` with a decorator which will do the ...@@ -2266,9 +2266,9 @@ The script just arranges to decorate ``foo`` with a decorator which will do the
conditional logging that's required. The decorator takes a logger as a parameter conditional logging that's required. The decorator takes a logger as a parameter
and attaches a memory handler for the duration of the call to the decorated and attaches a memory handler for the duration of the call to the decorated
function. The decorator can be additionally parameterised using a target handler, function. The decorator can be additionally parameterised using a target handler,
a level at which flushing should occur, and a capacity for the buffer. These a level at which flushing should occur, and a capacity for the buffer (number of
default to a :class:`~logging.StreamHandler` which writes to ``sys.stderr``, records buffered). These default to a :class:`~logging.StreamHandler` which
``logging.ERROR`` and ``100`` respectively. writes to ``sys.stderr``, ``logging.ERROR`` and ``100`` respectively.
Here's the script:: Here's the script::
......
...@@ -861,7 +861,8 @@ should, then :meth:`flush` is expected to do the flushing. ...@@ -861,7 +861,8 @@ should, then :meth:`flush` is expected to do the flushing.
.. class:: BufferingHandler(capacity) .. class:: BufferingHandler(capacity)
Initializes the handler with a buffer of the specified capacity. Initializes the handler with a buffer of the specified capacity. Here,
*capacity* means the number of logging records buffered.
.. method:: emit(record) .. method:: emit(record)
...@@ -885,12 +886,13 @@ should, then :meth:`flush` is expected to do the flushing. ...@@ -885,12 +886,13 @@ should, then :meth:`flush` is expected to do the flushing.
.. class:: MemoryHandler(capacity, flushLevel=ERROR, target=None, flushOnClose=True) .. class:: MemoryHandler(capacity, flushLevel=ERROR, target=None, flushOnClose=True)
Returns a new instance of the :class:`MemoryHandler` class. The instance is Returns a new instance of the :class:`MemoryHandler` class. The instance is
initialized with a buffer size of *capacity*. If *flushLevel* is not specified, initialized with a buffer size of *capacity* (number of records buffered).
:const:`ERROR` is used. If no *target* is specified, the target will need to be If *flushLevel* is not specified, :const:`ERROR` is used. If no *target* is
set using :meth:`setTarget` before this handler does anything useful. If specified, the target will need to be set using :meth:`setTarget` before this
*flushOnClose* is specified as ``False``, then the buffer is *not* flushed when handler does anything useful. If *flushOnClose* is specified as ``False``,
the handler is closed. If not specified or specified as ``True``, the previous then the buffer is *not* flushed when the handler is closed. If not specified
behaviour of flushing the buffer will occur when the handler is closed. or specified as ``True``, the previous behaviour of flushing the buffer will
occur when the handler is closed.
.. versionchanged:: 3.6 .. versionchanged:: 3.6
The *flushOnClose* parameter was added. The *flushOnClose* parameter was added.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment