本文整理汇总了PHP中Zend\Log\Logger::addPriority方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::addPriority方法的具体用法?PHP Logger::addPriority怎么用?PHP Logger::addPriority使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Log\Logger
的用法示例。
在下文中一共展示了Logger::addPriority方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddLogPriority
public function testAddLogPriority()
{
$logger = new Logger($this->writer);
$logger->addPriority('EIGHT', $priority = 8);
$logger->eight($message = 'eight message');
rewind($this->log);
$logdata = stream_get_contents($this->log);
$this->assertContains((string) $priority, $logdata);
$this->assertContains($message, $logdata);
}
示例2: testPriorityDuplicates
/**
* @group ZF-10170
*/
public function testPriorityDuplicates()
{
$logger = new Logger();
$mock = new Log\Writer\Mock();
$logger->addWriter($mock);
try {
$logger->addPriority('emerg', 8);
$this->fail();
} catch (\Exception $e) {
$this->assertType('Zend\\Log\\Exception', $e);
$this->assertEquals('Existing priorities cannot be overwritten', $e->getMessage());
}
try {
$logger->log('zf10170', 0);
$logger->log('clone zf10170', 8);
$this->fail();
} catch (\Exception $e) {
$this->assertType('Zend\\Log\\Exception', $e);
$this->assertEquals('Bad log priority', $e->getMessage());
}
$this->assertEquals(0, $mock->events[0]['priority']);
$this->assertEquals('EMERG', $mock->events[0]['priorityName']);
$this->assertFalse(array_key_exists(1, $mock->events));
}
示例3: testExceptionIsThrownOnPriorityDuplicates
/**
* @group ZF-10170
*/
public function testExceptionIsThrownOnPriorityDuplicates()
{
$logger = new Logger();
$mock = new Log\Writer\Mock();
$logger->addWriter($mock);
$this->setExpectedException('Zend\\Log\\Exception\\InvalidArgumentException', 'Existing priorities cannot be overwritten');
$logger->addPriority('emerg', 8);
}