mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-06 13:16:39 +02:00
Remove duplicate call to BufferHandler::close, fixes #386
This commit is contained in:
@@ -91,6 +91,13 @@ class BufferHandler extends AbstractHandler
|
||||
$this->clear();
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
// suppress the parent behavior since we already have register_shutdown_function()
|
||||
// to call close(), and the reference contained there will prevent this from being
|
||||
// GC'd until the end of the request
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@@ -16,6 +16,8 @@ use Monolog\Logger;
|
||||
|
||||
class BufferHandlerTest extends TestCase
|
||||
{
|
||||
private $shutdownCheckHandler;
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\BufferHandler::__construct
|
||||
* @covers Monolog\Handler\BufferHandler::handle
|
||||
@@ -38,15 +40,22 @@ class BufferHandlerTest extends TestCase
|
||||
* @covers Monolog\Handler\BufferHandler::close
|
||||
* @covers Monolog\Handler\BufferHandler::flush
|
||||
*/
|
||||
public function testDestructPropagatesRecords()
|
||||
public function testPropagatesRecordsAtEndOfRequest()
|
||||
{
|
||||
$test = new TestHandler();
|
||||
$handler = new BufferHandler($test);
|
||||
$handler->handle($this->getRecord(Logger::WARNING));
|
||||
$handler->handle($this->getRecord(Logger::DEBUG));
|
||||
$handler->__destruct();
|
||||
$this->assertTrue($test->hasWarningRecords());
|
||||
$this->assertTrue($test->hasDebugRecords());
|
||||
$this->shutdownCheckHandler = $test;
|
||||
register_shutdown_function(array($this, 'checkPropagation'));
|
||||
}
|
||||
|
||||
public function checkPropagation()
|
||||
{
|
||||
if (!$this->shutdownCheckHandler->hasWarningRecords() || !$this->shutdownCheckHandler->hasDebugRecords()) {
|
||||
echo '!!! BufferHandlerTest::testPropagatesRecordsAtEndOfRequest failed to verify that the messages have been propagated' . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user