1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-06 05:07:36 +02:00

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.
This commit is contained in:
Nils Adermann
2016-04-14 16:56:59 -04:00
parent 5f56ed5212
commit c677398c76

View File

@@ -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;
}