diff --git a/src/Monolog/Handler/BufferHandler.php b/src/Monolog/Handler/BufferHandler.php index 183d239a..1085d0a7 100644 --- a/src/Monolog/Handler/BufferHandler.php +++ b/src/Monolog/Handler/BufferHandler.php @@ -88,8 +88,7 @@ class BufferHandler extends AbstractHandler } $this->handler->handleBatch($this->buffer); - $this->bufferSize = 0; - $this->buffer = array(); + $this->clear(); } /** @@ -99,4 +98,13 @@ class BufferHandler extends AbstractHandler { $this->flush(); } + + /** + * Clears the buffer without flushing any messages down to the wrapped handler. + */ + public function clear() + { + $this->bufferSize = 0; + $this->buffer = array(); + } } diff --git a/src/Monolog/Handler/FingersCrossedHandler.php b/src/Monolog/Handler/FingersCrossedHandler.php index 6c66ea04..981e524c 100644 --- a/src/Monolog/Handler/FingersCrossedHandler.php +++ b/src/Monolog/Handler/FingersCrossedHandler.php @@ -135,4 +135,15 @@ class FingersCrossedHandler extends AbstractHandler { $this->buffering = true; } + + /** + * Clears the buffer without flushing any messages down to the wrapped handler. + * + * It also resets the handler to its initial buffering state. + */ + public function clear() + { + $this->buffer = array(); + $this->reset(); + } }