1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-29 11:26:09 +01:00

Merge pull request #1531 from marcvdm/reset-filter-handler

Reset wrapped handler of the FilterHandler
This commit is contained in:
Jordi Boggiano
2021-01-27 16:35:09 +01:00
committed by GitHub
2 changed files with 27 additions and 0 deletions

View File

@@ -185,5 +185,9 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
public function reset()
{
$this->resetProcessors();
if ($this->getHandler() instanceof ResettableInterface) {
$this->getHandler()->reset();
}
}
}

View File

@@ -180,4 +180,27 @@ class FilterHandlerTest extends TestCase
$handler->handleBatch(array());
$this->assertSame(array(), $test->getRecords());
}
/**
* @covers Monolog\Handler\FilterHandler::handle
* @covers Monolog\Handler\FilterHandler::reset
*/
public function testResetTestHandler()
{
$test = new TestHandler();
$handler = new FilterHandler($test, [Logger::INFO, Logger::ERROR]);
$handler->handle($this->getRecord(Logger::INFO));
$this->assertTrue($test->hasInfoRecords());
$handler->handle($this->getRecord(Logger::ERROR));
$this->assertTrue($test->hasErrorRecords());
$handler->reset();
$this->assertFalse($test->hasInfoRecords());
$this->assertFalse($test->hasInfoRecords());
$this->assertSame(array(), $test->getRecords());
}
}