mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-23 17:46:09 +02:00
Add Logger::close and clarify what close and reset do plus
This commit is contained in:
@@ -177,8 +177,6 @@ abstract class AbstractHandler implements HandlerInterface, ResettableInterface
|
||||
|
||||
public function reset()
|
||||
{
|
||||
$this->close();
|
||||
|
||||
foreach ($this->processors as $processor) {
|
||||
if ($processor instanceof ResettableInterface) {
|
||||
$processor->reset();
|
||||
|
@@ -73,6 +73,11 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
|
||||
}
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
self::resetStatic();
|
||||
}
|
||||
|
||||
public function reset()
|
||||
{
|
||||
self::resetStatic();
|
||||
|
@@ -118,6 +118,8 @@ class BufferHandler extends AbstractHandler
|
||||
|
||||
public function reset()
|
||||
{
|
||||
$this->flush();
|
||||
|
||||
parent::reset();
|
||||
|
||||
if ($this->handler instanceof ResettableInterface) {
|
||||
|
@@ -131,27 +131,14 @@ class FingersCrossedHandler extends AbstractHandler
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
if (null !== $this->passthruLevel) {
|
||||
$level = $this->passthruLevel;
|
||||
$this->buffer = array_filter($this->buffer, function ($record) use ($level) {
|
||||
return $record['level'] >= $level;
|
||||
});
|
||||
if (count($this->buffer) > 0) {
|
||||
$this->handler->handleBatch($this->buffer);
|
||||
$this->buffer = array();
|
||||
}
|
||||
}
|
||||
$this->flushBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the state of the handler. Stops forwarding records to the wrapped handler.
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
parent::reset();
|
||||
$this->flushBuffer();
|
||||
|
||||
$this->buffer = array();
|
||||
$this->buffering = true;
|
||||
parent::reset();
|
||||
|
||||
if ($this->handler instanceof ResettableInterface) {
|
||||
$this->handler->reset();
|
||||
@@ -168,4 +155,23 @@ class FingersCrossedHandler extends AbstractHandler
|
||||
$this->buffer = array();
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the state of the handler. Stops forwarding records to the wrapped handler.
|
||||
*/
|
||||
private function flushBuffer()
|
||||
{
|
||||
if (null !== $this->passthruLevel) {
|
||||
$level = $this->passthruLevel;
|
||||
$this->buffer = array_filter($this->buffer, function ($record) use ($level) {
|
||||
return $record['level'] >= $level;
|
||||
});
|
||||
if (count($this->buffer) > 0) {
|
||||
$this->handler->handleBatch($this->buffer);
|
||||
}
|
||||
}
|
||||
|
||||
$this->buffer = array();
|
||||
$this->buffering = true;
|
||||
}
|
||||
}
|
||||
|
@@ -129,4 +129,16 @@ class RollbarHandler extends AbstractProcessingHandler
|
||||
{
|
||||
$this->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->flush();
|
||||
|
||||
parent::reset();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -66,6 +66,18 @@ class RotatingFileHandler extends StreamHandler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
parent::reset();
|
||||
|
||||
if (true === $this->mustRotate) {
|
||||
$this->rotate();
|
||||
}
|
||||
}
|
||||
|
||||
public function setFilenameFormat($filenameFormat, $dateFormat)
|
||||
{
|
||||
if (!preg_match('{^Y(([/_.-]?m)([/_.-]?d)?)?$}', $dateFormat)) {
|
||||
|
Reference in New Issue
Block a user