php Zend-Log-Logger类(方法)实例源码

下面列出了php Zend-Log-Logger 类(方法)源码代码实例,从而了解它的用法。

作者:mb-te    项目:zf-lo   
/**
  * @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];
 }

作者:camelcasetechs    项目:certigat   
/**
  * 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;
 }

作者:ifigenij    项目:serve   
/**
  * 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;
 }

作者:shitikovkiril    项目:LearnZF   
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]);
 }

作者:samsonasi    项目:LosLo   
public static function generateFileLogger($logFile, $logDir)
 {
     $fileName = static::validateLogFile($logFile, $logDir);
     $zendLogLogger = new Logger();
     $zendLogLogger->addWriter(new Stream($fileName));
     return new PsrLoggerAdapter($zendLogLogger);
 }

作者:jsnshrm    项目:Sum   
/**
  * 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);
 }

作者:spooner7    项目:dream-cm   
/**
  * 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);
     }
 }

作者:sumiyosh    项目:BokunoZF   
/**
  * @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;
 }

作者:ancgat    项目:Zf2LdapAut   
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();
 }

作者:eddiejaoud    项目:zf2-logge   
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);
 }

作者:simplicity-a    项目:NewReli   
/**
  * 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;
 }

作者:ingzep    项目:ProNo   
public function logInfo($message)
 {
     $log = new Logger();
     $writer = new Stream('pronoi.log');
     $log->addWriter($writer);
     $log->log(Logger::INFO, $message);
 }

作者:stgne    项目:phpari   
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();
 }

作者:v2-lab    项目:cellavita-we   
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;
     }
 }

作者:NguyenQuiDuon    项目:Funixtes   
/**
  *
  * @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;
 }

作者:wormlin    项目:phpari   
public function __construct()
 {
     $configFile = __DIR__ . '/../config.yml';
     $value = Yaml::parse(file_get_contents($configFile));
     $ariAddress = $value['examples']['client']['ari_address'];
     $dialString = $value['examples']['dial_example']['dial_string'];
     $logger = new Log\Logger();
     $logWriter = new Log\Writer\Stream("php://output");
     $logger->addWriter($logWriter);
     //$filter = new \Zend\Log\Filter\SuppressFilter(true);
     $filter = new Log\Filter\Priority(Log\Logger::NOTICE);
     $logWriter->addFilter($filter);
     // Connect to the ARI server
     $this->client = new Phparia($logger);
     $this->client->connect($ariAddress);
     $this->client->getAriClient()->onConnect(function () use($dialString) {
         try {
             $this->client->channels()->createChannel($dialString, null, null, null, null, $this->client->getStasisApplicationName(), 'dialed', '8185551212', 30, null, null, array('MYVARIABLE' => 'value'));
         } catch (ServerException $e) {
             $this->log($e->getMessage());
         }
     });
     // Listen for the stasis start
     $this->client->onStasisStart(function (StasisStart $event) use($dialString) {
         if (count($event->getArgs()) > 0 && $event->getArgs()[0] === 'dialed') {
             $this->log('Detected outgoing call with variable MYVARIABLE=' . $event->getChannel()->getVariable('MYVARIABLE')->getValue());
             // Put the new channel in a bridge
             $channel = $event->getChannel();
             $this->bridge = $this->client->bridges()->createBridge(uniqid(), 'dtmf_events, mixing', 'dial_example_bridge');
             $this->bridge->addChannel($channel->getId());
         }
     });
     $this->client->run();
 }

作者:rsk    项目:BEAR.Packag   
/**
  * Provide instance
  *
  * @return CacheAdapter
  */
 public function get()
 {
     $logger = new Logger();
     $writer = new Stream($this->logDir . '/app.log');
     $logger->addWriter($writer);
     return new Zf2LogAdapter($logger);
 }

作者:ahyswan    项目:eva-engin   
public function perform()
 {
     $queueName = isset($this->args['name']) ? $this->args['name'] : 'error';
     $writer = new Log\Writer\Stream(EVA_PUBLIC_PATH . '/logs/' . $queueName . '.log');
     $logger = new Log\Logger();
     $logger->addWriter($writer);
     $logger->info("Worker {$queueName} is working");
 }

作者:andreas-serl    项目:athene   
/**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $logger = new Logger();
     $file = __DIR__ . '/../../../../../logs/' . date('Y-m-d') . '-error.log';
     $writer = new Stream($file);
     $logger->addWriter($writer);
     return $logger;
 }

作者:michaelmouss    项目:zend-psr-lo   
public function testDirectLogCallsAreProxiedToTheZendLogger()
 {
     $logLevel = LogLevel::INFO;
     $message = 'it works!';
     $extra = array('foo' => 'bar');
     $this->zendLogger->shouldReceive('log')->once()->with($this->psrLogger->getZendLogLevel($logLevel), $message, $extra)->andReturnSelf();
     call_user_func(array($this->psrLogger, 'log'), $logLevel, $message, $extra);
 }


问题


面经


文章

微信
公众号

扫码关注公众号