1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-21 08:36:33 +02:00

Merge branch '1.x'

This commit is contained in:
Jordi Boggiano
2016-05-20 19:40:36 +01:00
11 changed files with 223 additions and 37 deletions

View File

@@ -81,6 +81,26 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
return true;
}
/**
* Manually activate this logger regardless of the activation strategy
*/
public function activate()
{
if ($this->stopBuffering) {
$this->buffering = false;
}
if (!$this->handler instanceof HandlerInterface) {
$record = end($this->buffer) ?: null;
$this->handler = call_user_func($this->handler, $record, $this);
if (!$this->handler instanceof HandlerInterface) {
throw new \RuntimeException("The factory callable should return a HandlerInterface");
}
}
$this->handler->handleBatch($this->buffer);
$this->buffer = array();
}
/**
* {@inheritdoc}
*/
@@ -96,17 +116,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
array_shift($this->buffer);
}
if ($this->activationStrategy->isHandlerActivated($record)) {
if ($this->stopBuffering) {
$this->buffering = false;
}
if (!$this->handler instanceof HandlerInterface) {
$this->handler = call_user_func($this->handler, $record, $this);
if (!$this->handler instanceof HandlerInterface) {
throw new \RuntimeException("The factory callable should return a HandlerInterface");
}
}
$this->handler->handleBatch($this->buffer);
$this->buffer = array();
$this->activate();
}
} else {
$this->handler->handle($record);