1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-07-30 01:40:30 +02:00

Added a Processor stack to the Logger class, added getHandler() to check if any handler is going to handle the message before processing it, handlers are now calling their parent in a chain

This commit is contained in:
Jordi Boggiano
2011-02-21 20:38:18 +01:00
parent 8d27400122
commit a426ce2815
5 changed files with 93 additions and 52 deletions

View File

@@ -29,8 +29,36 @@ class AbstractHandlerTest extends \PHPUnit_Framework_TestCase
public function testHandleBubbling()
{
$handler = new TestHandler(Logger::DEBUG, true);
$this->assertFalse($handler->handle($this->getMessage()));
$topHandler = new TestHandler(Logger::DEBUG, true);
$bottomHandler = new TestHandler(Logger::INFO);
$topHandler->setParent($bottomHandler);
$this->assertTrue($topHandler->handle($this->getMessage()));
$this->assertTrue($bottomHandler->hasWarningMessages());
}
public function testHandleNotBubbling()
{
$topHandler = new TestHandler(Logger::DEBUG);
$bottomHandler = new TestHandler(Logger::INFO);
$topHandler->setParent($bottomHandler);
$this->assertTrue($topHandler->handle($this->getMessage()));
$this->assertFalse($bottomHandler->hasWarningMessages());
}
public function testGetHandlerReturnEarly()
{
$topHandler = new TestHandler(Logger::DEBUG);
$bottomHandler = new TestHandler(Logger::INFO);
$topHandler->setParent($bottomHandler);
$this->assertEquals($topHandler, $topHandler->getHandler($this->getMessage()));
}
public function testGetHandlerReturnsParent()
{
$topHandler = new TestHandler(Logger::ERROR);
$bottomHandler = new TestHandler(Logger::INFO);
$topHandler->setParent($bottomHandler);
$this->assertEquals($bottomHandler, $topHandler->getHandler($this->getMessage()));
}
protected function getMessage($level = Logger::WARNING)