From c677398c76961bcbe55ec1da2cedce5585df6577 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 14 Apr 2016 16:56:59 -0400 Subject: [PATCH] Provide means to manually activate a FingersCrossedHandler This is useful if you have a FingersCrossedHandler set up and some where in your application are interested in all output regardless of whether the threshold is actually reached. For example to temporarily debug some problem. One can replace the handler in that spot, but this is signifcantly easier to use. --- src/Monolog/Handler/FingersCrossedHandler.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Monolog/Handler/FingersCrossedHandler.php b/src/Monolog/Handler/FingersCrossedHandler.php index 30a85dd6..6036c15e 100644 --- a/src/Monolog/Handler/FingersCrossedHandler.php +++ b/src/Monolog/Handler/FingersCrossedHandler.php @@ -36,6 +36,7 @@ class FingersCrossedHandler extends AbstractHandler protected $buffer = array(); protected $stopBuffering; protected $passthruLevel; + protected $overrideActivated = false; /** * @param callable|HandlerInterface $handler Handler or factory callable($record, $fingersCrossedHandler). @@ -79,6 +80,14 @@ class FingersCrossedHandler extends AbstractHandler return true; } + /** + * Manually activate this logger regardless of the activation strategy + */ + public function activate() + { + $this->overrideActivated = true; + } + /** * {@inheritdoc} */ @@ -95,7 +104,7 @@ class FingersCrossedHandler extends AbstractHandler if ($this->bufferSize > 0 && count($this->buffer) > $this->bufferSize) { array_shift($this->buffer); } - if ($this->activationStrategy->isHandlerActivated($record)) { + if ($this->overrideActivated || $this->activationStrategy->isHandlerActivated($record)) { if ($this->stopBuffering) { $this->buffering = false; }