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


PHP Logger::getWriters方法代碼示例

本文整理匯總了PHP中Zend\Log\Logger::getWriters方法的典型用法代碼示例。如果您正苦於以下問題:PHP Logger::getWriters方法的具體用法?PHP Logger::getWriters怎麽用?PHP Logger::getWriters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Log\Logger的用法示例。


在下文中一共展示了Logger::getWriters方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 public function setUp()
 {
     $logger = new Logger();
     $writers = $logger->getWriters();
     $this->writer = new LogWriter();
     $writers->insert($this->writer, 1);
     $this->listener = new ErrorListener($logger);
 }
開發者ID:simplicity-ag,項目名稱:NewRelic,代碼行數:8,代碼來源:ErrorListenerTest.php

示例2: createService

 /**
  * {@inheritDoc}
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     // create new logger
     $logger = new Logger();
     // get application config as array
     $config = $serviceLocator->get('config');
     $config = $config['dherrorlogging'];
     // get priority
     $priority = Logger::WARN;
     if (isset($config['priority']) && is_int($config['priority'])) {
         $priority = $config['priority'];
     }
     $priorityFilter = new Filter\Priority($priority);
     // get writers from config
     if (!empty($config['log_writers']) && is_array($config['log_writers'])) {
         $logWriterManager = $serviceLocator->get('LogWriterManager');
         foreach ($config['log_writers'] as $writerSpecs) {
             // skip if no name
             if (empty($writerSpecs['name']) || !is_string($writerSpecs['name'])) {
                 continue;
             }
             // get options
             $options = array();
             if (!empty($writerSpecs['options']) && is_array($writerSpecs['options'])) {
                 $options = $writerSpecs['options'];
             }
             // check if it is one of the known writers that can be created via config or retrieved from service manager
             if ($logWriterManager->has($writerSpecs['name'])) {
                 $writer = $logWriterManager->get($writerSpecs['name'], $options);
                 // add priority filter
                 $writer->addFilter($priorityFilter);
                 // add writer to logger
                 $logger->addWriter($writer);
             }
         }
     }
     // add processors which will add some extra helpful info (IP, URI, trace,..) to the final log.
     $processor = $serviceLocator->get('LogProcessorManager')->get('DhErrorLogging\\LoggerProcessor');
     $logger->addProcessor($processor);
     // Logger needs at least one writer. Check if there are any, else add empty one.
     if ($logger->getWriters()->count() == 0) {
         // Support for PHP7 / Zend >= 2.4
         if (class_exists('\\Zend\\Log\\Writer\\Noop')) {
             $logger->addWriter(new Writer\Noop());
         } else {
             $logger->addWriter(new Writer\Null());
         }
     }
     return $logger;
 }
開發者ID:brighten01,項目名稱:zf2-openstack-api,代碼行數:53,代碼來源:LoggerFactory.php

示例3: testOptionsWithWriterOptions

 public function testOptionsWithWriterOptions()
 {
     $options = array('writers' => array(array('name' => 'stream', 'options' => array('stream' => 'php://output', 'log_separator' => 'foo'))));
     $logger = new Logger($options);
     $writers = $logger->getWriters()->toArray();
     $this->assertCount(1, $writers);
     $this->assertInstanceOf('Zend\\Log\\Writer\\Stream', $writers[0]);
     $this->assertEquals('foo', $writers[0]->getLogSeparator());
 }
開發者ID:rajanlamic,項目名稱:IntTest,代碼行數:9,代碼來源:LoggerTest.php


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