Closes #26559: Allow configuring flush-on-close behaviour of MemoryHandler.

This commit is contained in:
Vinay Sajip 2016-07-22 16:27:31 +01:00
parent d141531eb5
commit cccf6068fa
3 changed files with 54 additions and 8 deletions

View file

@ -806,12 +806,18 @@ should, then :meth:`flush` is expected to do the flushing.
overridden to implement custom flushing strategies.
.. class:: MemoryHandler(capacity, flushLevel=ERROR, target=None)
.. class:: MemoryHandler(capacity, flushLevel=ERROR, target=None, flushOnClose=True)
Returns a new instance of the :class:`MemoryHandler` class. The instance is
initialized with a buffer size of *capacity*. If *flushLevel* is not specified,
:const:`ERROR` is used. If no *target* is specified, the target will need to be
set using :meth:`setTarget` before this handler does anything useful.
set using :meth:`setTarget` before this handler does anything useful. If
*flushOnClose* is specified as ``False``, then the buffer is *not* flushed when
the handler is closed. If not specified or specified as ``True``, the previous
behaviour of flushing the buffer will occur when the handler is closed.
.. versionchanged:: 3.6
The *flushOnClose* parameter was added.
.. method:: close()