當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Logger::addPriority方法代碼示例

本文整理匯總了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);
 }
開發者ID:bradley-holt,項目名稱:zf2,代碼行數:10,代碼來源:LoggerTest.php

示例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));
 }
開發者ID:heiglandreas,項目名稱:zf2,代碼行數:27,代碼來源:LoggerTest.php

示例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);
 }
開發者ID:rexmac,項目名稱:zf2,代碼行數:11,代碼來源:LoggerTest.php


注:本文中的Zend\Log\Logger::addPriority方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。