/** * @covers Monolog\Handler\FilterHandler::handle * @covers Monolog\Handler\FilterHandler::setAcceptedLevels * @covers Monolog\Handler\FilterHandler::isHandling */ public function testHandleProcessOnlyNeededLevels() { $test = new TestHandler(); $handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE); $handler->handle($this->getRecord(Logger::DEBUG)); $this->assertFalse($test->hasDebugRecords()); $handler->handle($this->getRecord(Logger::INFO)); $this->assertTrue($test->hasInfoRecords()); $handler->handle($this->getRecord(Logger::NOTICE)); $this->assertTrue($test->hasNoticeRecords()); $handler->handle($this->getRecord(Logger::WARNING)); $this->assertFalse($test->hasWarningRecords()); $handler->handle($this->getRecord(Logger::ERROR)); $this->assertFalse($test->hasErrorRecords()); $handler->handle($this->getRecord(Logger::CRITICAL)); $this->assertFalse($test->hasCriticalRecords()); $handler->handle($this->getRecord(Logger::ALERT)); $this->assertFalse($test->hasAlertRecords()); $handler->handle($this->getRecord(Logger::EMERGENCY)); $this->assertFalse($test->hasEmergencyRecords()); $test = new TestHandler(); $handler = new FilterHandler($test, array(Logger::INFO, Logger::ERROR)); $handler->handle($this->getRecord(Logger::DEBUG)); $this->assertFalse($test->hasDebugRecords()); $handler->handle($this->getRecord(Logger::INFO)); $this->assertTrue($test->hasInfoRecords()); $handler->handle($this->getRecord(Logger::NOTICE)); $this->assertFalse($test->hasNoticeRecords()); $handler->handle($this->getRecord(Logger::ERROR)); $this->assertTrue($test->hasErrorRecords()); $handler->handle($this->getRecord(Logger::CRITICAL)); $this->assertFalse($test->hasCriticalRecords()); }
public function testNotice() { $context = array("foo" => "bar"); Simple::notice("hello", $context); $this->assertTrue($this->handler->hasNoticeRecords()); foreach ($this->handler->getRecords() as $record) { $this->assertEquals("hello", $record['message']); $this->assertEquals("NOTICE", $record['level_name']); $this->assertEquals($context, $record['context']); } }
public function testNoticeExceptionErrorLog() { $this->assertFalse($this->monologHandler->hasNoticeRecords()); $this->logHandler->handle(new \ErrorException('test exception', 0, E_NOTICE)); $this->assertTrue($this->monologHandler->hasNoticeRecords()); }