本文整理匯總了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);
}