1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-23 09:36:11 +02:00

Merge branch '1.x'

This commit is contained in:
Jordi Boggiano
2018-11-04 18:40:32 +01:00
27 changed files with 654 additions and 24 deletions

View File

@@ -11,6 +11,8 @@
namespace Monolog\Handler;
use Monolog\ResettableInterface;
/**
* Base Handler class providing the Handler structure
*
@@ -19,7 +21,7 @@ namespace Monolog\Handler;
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author Christophe Coevoet <stof@notk.org>
*/
abstract class AbstractProcessingHandler extends AbstractHandler implements ProcessableHandlerInterface, FormattableHandlerInterface
abstract class AbstractProcessingHandler extends AbstractHandler implements ProcessableHandlerInterface, FormattableHandlerInterface, ResettableInterface
{
use ProcessableHandlerTrait;
use FormattableHandlerTrait;
@@ -48,4 +50,15 @@ abstract class AbstractProcessingHandler extends AbstractHandler implements Proc
* Writes the record down to the log of the implementing handler
*/
abstract protected function write(array $record): void;
public function reset()
{
$this->close();
foreach ($this->processors as $processor) {
if ($processor instanceof ResettableInterface) {
$processor->reset();
}
}
}
}

View File

@@ -70,14 +70,19 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
} elseif ($format === 'js') {
static::writeOutput(static::generateScript());
}
static::reset();
static::resetStatic();
}
}
public function reset()
{
self::resetStatic();
}
/**
* Forget all logged records
*/
public static function reset(): void
public static function resetStatic(): void
{
static::$records = [];
}

View File

@@ -12,6 +12,7 @@
namespace Monolog\Handler;
use Monolog\Logger;
use Monolog\ResettableInterface;
/**
* Buffers all records until closing the handler and then pass them as batch.
@@ -114,4 +115,13 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
$this->bufferSize = 0;
$this->buffer = [];
}
public function reset()
{
parent::reset();
if ($this->handler instanceof ResettableInterface) {
$this->handler->reset();
}
}
}

View File

@@ -14,6 +14,7 @@ namespace Monolog\Handler;
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
use Monolog\Handler\FingersCrossed\ActivationStrategyInterface;
use Monolog\Logger;
use Monolog\ResettableInterface;
/**
* Buffers all records until a certain level is reached
@@ -147,7 +148,14 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
*/
public function reset()
{
parent::reset();
$this->buffer = array();
$this->buffering = true;
if ($this->handler instanceof ResettableInterface) {
$this->handler->reset();
}
}
/**

View File

@@ -12,6 +12,7 @@
namespace Monolog\Handler;
use Monolog\Formatter\FormatterInterface;
use Monolog\ResettableInterface;
/**
* Forwards records to multiple handlers
@@ -90,6 +91,17 @@ class GroupHandler extends Handler implements ProcessableHandlerInterface
}
}
public function reset()
{
parent::reset();
foreach ($this->handlers as $handler) {
if ($handler instanceof ResettableInterface) {
$handler->reset();
}
}
}
/**
* {@inheritdoc}
*/

View File

@@ -11,6 +11,7 @@
namespace Monolog\Handler;
use Monolog\ResettableInterface;
use Monolog\Formatter\FormatterInterface;
/**
@@ -30,7 +31,7 @@ use Monolog\Formatter\FormatterInterface;
*
* @author Alexey Karapetov <alexey@karapetov.com>
*/
class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, FormattableHandlerInterface
class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, FormattableHandlerInterface, ResettableInterface
{
/**
* @var HandlerInterface
@@ -127,4 +128,11 @@ class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, F
throw new \LogicException('The wrapped handler does not implement ' . FormattableHandlerInterface::class);
}
public function reset()
{
if ($this->handler instanceof ResettableInterface) {
return $this->handler->reset();
}
}
}

View File

@@ -18,7 +18,7 @@ use Raven_Client;
/**
* Handler to send messages to a Sentry (https://github.com/getsentry/sentry) server
* using raven-php (https://github.com/getsentry/raven-php)
* using sentry-php (https://github.com/getsentry/sentry-php)
*
* @author Marc Abramowitz <marc@marc-abramowitz.com>
*/