当前位置: 首页>>代码示例>>PHP>>正文


PHP Log\Logger类代码示例

本文整理汇总了PHP中Zend\Log\Logger的典型用法代码示例。如果您正苦于以下问题:PHP Logger类的具体用法?PHP Logger怎么用?PHP Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Logger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getLogger

 /**
  * @param       $sFile
  * @param array $aOptions
  *
  * @return mixed
  */
 protected function _getLogger($sFile, array $aOptions = [])
 {
     $sKey = md5($sFile);
     if (!isset($this->_aLoggers[$sKey])) {
         $aWriterConfig = $this->_aConfig['writer'];
         $oLogger = new Logger($aOptions);
         if (isset($aWriterConfig['file']['enabled']) && $aWriterConfig['file']['enabled']) {
             $oFileWriter = $this->_getFileWriter($sFile);
             if (is_object($oFileWriter)) {
                 $oLogger->addWriter($oFileWriter);
             }
         }
         if (isset($aWriterConfig['mail']['enabled']) && $aWriterConfig['mail']['enabled']) {
             $oMailWriter = $this->_getMailWriter();
             if (is_object($oMailWriter)) {
                 $oLogger->addWriter($oMailWriter);
             }
         }
         if (isset($aWriterConfig['graylog']['enabled']) && $aWriterConfig['graylog']['enabled']) {
             $oGraylogWriter = $this->_getGraylogWriter($sFile);
             if (is_object($oGraylogWriter)) {
                 $oLogger->addWriter($oGraylogWriter);
             }
         }
         $this->_aLoggers[$sKey] = $oLogger;
     }
     return $this->_aLoggers[$sKey];
 }
开发者ID:mb-tec,项目名称:zf-log,代码行数:34,代码来源:LogService.php

示例2: createService

 /**
  * Prepare Logger service
  * 
  * 
  * @uses Logger
  * 
  * @access public
  * @param ServiceLocatorInterface $serviceLocator
  * @return Logger
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $logger = new Logger();
     $writer = new Stream(self::ERROR_LOG_FILE);
     $logger->addWriter($writer);
     return $logger;
 }
开发者ID:camelcasetechsd,项目名称:certigate,代码行数:17,代码来源:LoggerFactory.php

示例3: createService

 /**
  * Metoda inicializira crpalka service(cs) predno se začne cs uporabljat
  * 
  * @param ServiceLocatorInterface $serviceLocator
  * @return \Crpalka\Service\CrpalkaService
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     //pridobitev configuracije
     $options = $serviceLocator->get('Config');
     //parsanje potrebnih podatkov
     $poti = $options['crpalka']['pravila']['pot'];
     $owningSide = $options['crpalka']['pravila']['owningside'];
     $NeOwningSide = $options['crpalka']['pravila']['neowningside'];
     $ident = $options['crpalka']['pravila']['ident'];
     $service = new CrpalkaService();
     //inicializacija propertijev
     $service->setEmIzvor($serviceLocator->get("doctrine.entitymanager.orm_default"));
     $service->setEmCilj($serviceLocator->get("doctrine.entitymanager.orm_dest"));
     $service->setEntityMetadataFactory($serviceLocator->get("entity.metadata.factory"));
     $service->setPoljeEntitet(new ArrayCollection());
     $service->setPoljePravil(new ArrayCollection($poti));
     $service->setPoljeOwningSide(new ArrayCollection($owningSide));
     $service->setPoljeNeOwningSide(new ArrayCollection($NeOwningSide));
     $service->setPoljeIdent(new ArrayCollection($ident));
     //deklaracija in inicializacija loggerja
     $logger = new Logger();
     $log = __DIR__ . '/../../../../../data/crpalka.log';
     $writer = new Writer\Stream($log);
     $logger->addWriter($writer);
     $logger->registerErrorHandler($logger);
     $service->setLogger($logger);
     return $service;
 }
开发者ID:ifigenija,项目名称:server,代码行数:34,代码来源:CrpalkaServiceFactory.php

示例4: indexAction

 public function indexAction()
 {
     $request = $this->getRequest();
     $logContent = '';
     // initialize when no submit anymore
     $data = [];
     $data['logmessage'] = $this->form->get('logmessage')->getValue();
     if ($request->isPost()) {
         $this->form->setData($request->getPost());
         if ($this->form->isValid()) {
             $data = $this->form->getData();
             $this->loggerPriority = $data['logpriority'];
             if ($data['logformat'] !== 'simple') {
                 $this->loggerConfig['writers'][0]['options']['formatter']['name'] = $data['logformat'];
                 unset($this->loggerConfig['writers'][0]['options']['formatter']['options']);
             }
         }
     }
     $logger = new Logger($this->loggerConfig);
     // save log data to buffer and make it variable
     ob_start();
     $logger->log((int) $this->loggerPriority, $data['logmessage']);
     $logContent = ob_get_clean();
     return new ViewModel(['form' => $this->form, 'logContent' => $logContent]);
 }
开发者ID:shitikovkirill,项目名称:LearnZF2,代码行数:25,代码来源:IndexController.php

示例5: generateFileLogger

 public static function generateFileLogger($logFile, $logDir)
 {
     $fileName = static::validateLogFile($logFile, $logDir);
     $zendLogLogger = new Logger();
     $zendLogLogger->addWriter(new Stream($fileName));
     return new PsrLoggerAdapter($zendLogLogger);
 }
开发者ID:samsonasik,项目名称:LosLog,代码行数:7,代码来源:AbstractLogger.php

示例6: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->stream = fopen('php://temp', 'r+');
     $this->log = new Logger();
     $this->log->addWriter(new Stream($this->stream));
     $this->adapter = new Zf2LogAdapter($this->log);
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:11,代码来源:Zf2LogAdapterTest.php

示例7: initProfiler

 /**
  * Init profiler
  */
 public function initProfiler(MvcEvent $e)
 {
     try {
         $writer = new FirePhp();
         $logger = new Logger();
         $logger->addWriter($writer);
         $logger->info('memory usage: ' . memory_get_usage(true) / 1024 / 1024 . 'Mb');
         $logger->info('page execution time: ' . (microtime(true) - APPLICATION_START));
         // get sql profiler
         if (null !== ($sqlProfiler = $this->serviceLocator->get('Zend\\Db\\Adapter\\Adapter')->getProfiler())) {
             $queriesTotalTime = 0;
             foreach ($sqlProfiler->getProfiles() as $query) {
                 $base = ['time' => $query['elapse'], 'query' => $query['sql']];
                 $queriesTotalTime += $query['elapse'];
                 if (!empty($query['parameters'])) {
                     $params = [];
                     foreach ($query['parameters'] as $key => $value) {
                         $params[$key] = $value;
                     }
                     $base['params'] = $params;
                 }
                 $logger->info('', $base);
             }
             $logger->info('sql queries total execution time: ' . $queriesTotalTime);
         }
     } catch (Exception $e) {
         ApplicationErrorLogger::log($e);
     }
 }
开发者ID:spooner77,项目名称:dream-cms,代码行数:32,代码来源:Module.php

示例8: getLogger

 /**
  * @param $log_path
  * @return ZendLogger
  */
 public static function getLogger($log_path)
 {
     if (!self::$logger) {
         #region ディレクトリ生成
         $date = date('Ym');
         $error_dir = $log_path . 'error/' . $date . '/';
         $info_dir = $log_path . 'info/' . $date . '/';
         if (!file_exists($error_dir)) {
             @mkdir($error_dir, 0777);
         }
         if (!file_exists($info_dir)) {
             @mkdir($info_dir, 0777);
         }
         #endregion
         #region log初期設定
         $logger = new ZendLogger();
         $writer_err = new Stream($error_dir . date('Y-m-d') . '.log');
         $writer_info = new Stream($info_dir . date('Y-m-d') . '.log');
         //エラーログの出力レベル変更
         $filter = new Priority(ZendLogger::WARN);
         $writer_err->addFilter($filter);
         $logger->addWriter($writer_err);
         $logger->addWriter($writer_info);
         #endregion
         self::$logger = $logger;
     }
     return self::$logger;
 }
开发者ID:sumiyoshi,项目名称:BokunoZF2,代码行数:32,代码来源:Logger.php

示例9: __construct

 public function __construct($config)
 {
     $this->config = $config;
     if (isset($this->config['log_dir'])) {
         if (!is_dir($this->config['log_dir'])) {
             try {
                 mkdir($this->config['log_dir']);
             } catch (Exception $exc) {
                 echo "<h1>Could not create log directory " . $this->config['log_dir'] . "</h1>";
                 echo $exc->getMessage();
             }
         }
     } else {
         $this->config['log_dir'] = "/tmp/ldap";
         if (!is_dir($this->config['log_dir'])) {
             try {
                 mkdir($this->config['log_dir']);
             } catch (Exception $exc) {
                 echo "<h1>Could not create log directory " . $this->config['log_dir'] . "</h1>";
                 echo $exc->getMessage();
             }
         }
     }
     $logger = new Logger();
     $writer = new LogWriter($config['log_dir'] . '/ldap.log');
     $logger->addWriter($writer);
     Logger::registerErrorHandler($logger);
     $this->logger = $logger;
     $this->logger->log(Logger::INFO, 'Starting LDAP Bind');
     $this->bind();
 }
开发者ID:ancgate,项目名称:Zf2LdapAuth,代码行数:31,代码来源:LdapInterface.php

示例10: setUp

 public function setUp()
 {
     $this->writer = new \Zend\Log\Writer\Mock();
     $this->logger = new \Zend\Log\Logger();
     $this->logger->addWriter($this->writer);
     $this->instance = new Response($this->logger);
 }
开发者ID:eddiejaoude,项目名称:zf2-logger,代码行数:7,代码来源:ResponseTest.php

示例11: createService

 /**
  * Create the NewRelic logger
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return Logger
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $logger = new Logger();
     $writer = $serviceLocator->get('NewRelic\\Log\\Writer');
     $logger->addWriter($writer);
     return $logger;
 }
开发者ID:simplicity-ag,项目名称:NewRelic,代码行数:13,代码来源:LoggerFactory.php

示例12: logInfo

 public function logInfo($message)
 {
     $log = new Logger();
     $writer = new Stream('pronoi.log');
     $log->addWriter($writer);
     $log->log(Logger::INFO, $message);
 }
开发者ID:ingzepe,项目名称:ProNoi,代码行数:7,代码来源:EmpleadoController.php

示例13: __construct

 public function __construct()
 {
     $configFile = __DIR__ . '/../config.yml';
     $value = Yaml::parse(file_get_contents($configFile));
     $ariAddress = $value['examples']['client']['ari_address'];
     $amiAddress = $value['examples']['client']['ami_address'];
     $logger = new Log\Logger();
     $logWriter = new Log\Writer\Stream("php://output");
     $logger->addWriter($logWriter);
     //$filter = new Log\Filter\SuppressFilter(true);
     $filter = new Log\Filter\Priority(Log\Logger::NOTICE);
     $logWriter->addFilter($filter);
     // Connect to the ARI server
     $client = new Phparia($logger);
     $client->connect($ariAddress, $amiAddress);
     $this->client = $client;
     // Listen for the stasis start
     $client->onStasisStart(function (StasisStart $event) {
         // Put the new channel in a bridge
         $channel = $event->getChannel();
         $bridge = $this->client->bridges()->createBridge(uniqid(), 'dtmf_events, mixing', 'bridgename');
         $this->client->bridges()->addChannel($bridge->getId(), $channel->getId());
         // Listen for DTMF and hangup when '#' is pressed
         $channel->onChannelDtmfReceived(function (ChannelDtmfReceived $event) use($channel) {
             $this->log("Got digit: {$event->getDigit()}");
             if ($event->getDigit() === '#') {
                 $channel->hangup();
             }
         });
         $this->client->getWsClient()->on('Hangup', function ($event) {
             $this->log('User hung up');
         });
     });
     $this->client->run();
 }
开发者ID:stgnet,项目名称:phparia,代码行数:35,代码来源:AriAmiExample.php

示例14: doRequest

 public static function doRequest($url, array $postData = null, $method = Request::METHOD_GET)
 {
     $client = self::getClientInstance();
     $client->resetParameters();
     $client->setEncType(Client::ENC_URLENCODED);
     $client->setUri($url);
     $client->setMethod($method);
     if ($postData === null) {
         $postData = array();
     }
     $postData['access_token'] = self::getSession()->accessToken;
     if ($method == Request::METHOD_POST && $postData !== null) {
         $client->setParameterPost($postData);
     }
     if (($method == Request::METHOD_GET || $method == Request::METHOD_DELETE) && $postData !== null) {
         $client->setParameterGet($postData);
     }
     $response = $client->send();
     if ($response->isSuccess()) {
         return JsonDecoder::decode($response->getBody(), Json::TYPE_ARRAY);
     } else {
         $logger = new Logger();
         $logger->addWriter(new Stream('data/logs/apiclient.log'));
         $logger->debug($response->getBody());
         return FALSE;
     }
 }
开发者ID:v2-labs,项目名称:cellavita-web,代码行数:27,代码来源:ApiClient.php

示例15: createService

 /**
  *
  * @author VanCK
  * @param ServiceLocatorInterface $sl
  * @return \Zend\Cache\StorageFactory
  */
 public function createService(ServiceLocatorInterface $sl)
 {
     $log = new Logger();
     $writer = new FirePhpWriter();
     $log->addWriter($writer);
     return $log;
 }
开发者ID:NguyenQuiDuong,项目名称:Funixtest,代码行数:13,代码来源:LogFactory.php


注:本文中的Zend\Log\Logger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。