1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-04 20:27:31 +02:00

Fix some resettableinterface usages

This commit is contained in:
Jordi Boggiano
2018-11-04 19:58:13 +01:00
parent 36b767dc02
commit dddc7ed781
6 changed files with 23 additions and 10 deletions

View File

@@ -13,7 +13,6 @@ namespace Monolog;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel; use Psr\Log\LogLevel;
use Monolog\Registry;
/** /**
* Monolog error handler * Monolog error handler

View File

@@ -12,13 +12,14 @@
namespace Monolog\Handler; namespace Monolog\Handler;
use Monolog\Logger; use Monolog\Logger;
use Monolog\ResettableInterface;
/** /**
* Base Handler class providing basic level/bubble support * Base Handler class providing basic level/bubble support
* *
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
abstract class AbstractHandler extends Handler abstract class AbstractHandler extends Handler implements ResettableInterface
{ {
protected $level = Logger::DEBUG; protected $level = Logger::DEBUG;
protected $bubble = true; protected $bubble = true;
@@ -88,4 +89,9 @@ abstract class AbstractHandler extends Handler
{ {
return $this->bubble; return $this->bubble;
} }
public function reset()
{
$this->close();
}
} }

View File

@@ -21,7 +21,7 @@ use Monolog\ResettableInterface;
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
* @author Christophe Coevoet <stof@notk.org> * @author Christophe Coevoet <stof@notk.org>
*/ */
abstract class AbstractProcessingHandler extends AbstractHandler implements ProcessableHandlerInterface, FormattableHandlerInterface, ResettableInterface abstract class AbstractProcessingHandler extends AbstractHandler implements ProcessableHandlerInterface, FormattableHandlerInterface
{ {
use ProcessableHandlerTrait; use ProcessableHandlerTrait;
use FormattableHandlerTrait; use FormattableHandlerTrait;
@@ -53,7 +53,7 @@ abstract class AbstractProcessingHandler extends AbstractHandler implements Proc
public function reset() public function reset()
{ {
$this->close(); parent::reset();
foreach ($this->processors as $processor) { foreach ($this->processors as $processor) {
if ($processor instanceof ResettableInterface) { if ($processor instanceof ResettableInterface) {

View File

@@ -13,6 +13,7 @@ namespace Monolog\Handler;
use Monolog\Formatter\LineFormatter; use Monolog\Formatter\LineFormatter;
use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\FormatterInterface;
use Monolog\ResettableInterface;
/** /**
* Handler sending logs to browser's javascript console with no browser extension required * Handler sending logs to browser's javascript console with no browser extension required
@@ -76,6 +77,8 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
public function reset() public function reset()
{ {
parent::reset();
self::resetStatic(); self::resetStatic();
} }

View File

@@ -28,7 +28,7 @@ use Monolog\ResettableInterface;
* *
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class FingersCrossedHandler extends Handler implements ProcessableHandlerInterface class FingersCrossedHandler extends Handler implements ProcessableHandlerInterface, ResettableInterface
{ {
use ProcessableHandlerTrait; use ProcessableHandlerTrait;
@@ -148,8 +148,6 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
*/ */
public function reset() public function reset()
{ {
parent::reset();
$this->buffer = array(); $this->buffer = array();
$this->buffering = true; $this->buffering = true;

View File

@@ -19,7 +19,7 @@ use Monolog\ResettableInterface;
* *
* @author Lenar Lõhmus <lenar@city.ee> * @author Lenar Lõhmus <lenar@city.ee>
*/ */
class GroupHandler extends Handler implements ProcessableHandlerInterface class GroupHandler extends Handler implements ProcessableHandlerInterface, ResettableInterface
{ {
use ProcessableHandlerTrait; use ProcessableHandlerTrait;
@@ -93,8 +93,6 @@ class GroupHandler extends Handler implements ProcessableHandlerInterface
public function reset() public function reset()
{ {
parent::reset();
foreach ($this->handlers as $handler) { foreach ($this->handlers as $handler) {
if ($handler instanceof ResettableInterface) { if ($handler instanceof ResettableInterface) {
$handler->reset(); $handler->reset();
@@ -102,6 +100,15 @@ class GroupHandler extends Handler implements ProcessableHandlerInterface
} }
} }
public function close()
{
parent::close();
foreach ($this->handlers as $handler) {
$handler->close();
}
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */