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


PHP Logger::writerPlugin方法代码示例

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


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

示例1: getLogger

 /**
  * @param   string  $type
  * @throws  \InvalidArgumentException
  * @return  \Zend\Log\Logger
  */
 public function getLogger($type)
 {
     static $serviceTr = array('\\' => '', '_' => ''), $mailServices = array('mail', 'zendlogwritermail');
     $type = (string) $type;
     if (!isset($this->config[$type])) {
         throw new Exception\InvalidArgumentException(sprintf('Type "%s" not registered in config', $type));
     }
     $logger = new Logger();
     if ($this->serviceLocator instanceof ServiceManager) {
         $logger->getWriterPluginManager()->addPeeringServiceManager($this->serviceLocator);
     }
     if (isset($this->config[$type]['writers'])) {
         foreach ($this->config[$type]['writers'] as $name => $config) {
             $name = isset($config['name']) ? (string) $config['name'] : $name;
             $options = isset($config['options']) ? (array) $config['options'] : null;
             $priority = isset($config['priority']) ? (int) $config['priority'] : null;
             if ($this->serviceLocator !== null && in_array(strtr(strtolower($name), $serviceTr), $mailServices)) {
                 $mailService = $this->serviceLocator->get('Zork\\Mail\\Service');
                 if (!isset($options['transport'])) {
                     $options['transport'] = $mailService->getTransport();
                 }
                 if (!isset($options['mail'])) {
                     $options['mail'] = array();
                 }
                 $options['mail'] = $mailService->createMessage($options['mail']);
             }
             $writer = $logger->writerPlugin($name, $options);
             if ($writer instanceof WriterInterface) {
                 if (isset($config['filters'])) {
                     foreach ($config['filters'] as $filterName => $filterConfig) {
                         $filterName = isset($filterConfig['name']) ? (string) $filterConfig['name'] : $filterName;
                         $filterOptions = isset($filterConfig['options']) ? (array) $filterConfig['options'] : null;
                         $filter = $writer->filterPlugin($filterName, $filterOptions);
                         $writer->addFilter($filter, $filterOptions);
                     }
                 }
                 if (isset($config['formatter']['name'])) {
                     $formatter = $writer->formatterPlugin($config['formatter']['name'], isset($config['formatter']['options']) ? $config['formatter']['options'] : array());
                     $writer->setFormatter($formatter);
                 }
             }
             $logger->addWriter($writer, $priority, $options);
         }
     }
     if (isset($this->config[$type]['processors'])) {
         foreach ($this->config[$type]['processors'] as $name => $config) {
             $name = isset($config['name']) ? (string) $config['name'] : $name;
             $options = isset($config['options']) ? (array) $config['options'] : null;
             $priority = isset($config['priority']) ? (int) $config['priority'] : null;
             $logger->addProcessor($name, $priority, $options);
         }
     }
     return $logger;
 }
开发者ID:gridguyz,项目名称:zork,代码行数:59,代码来源:LoggerManager.php

示例2: getFactories

 public function getFactories()
 {
     $smc = $this;
     return array('InoOicServer\\ContextStorage' => 'InoOicServer\\Context\\Storage\\StorageFactory', 'InoOicServer\\SessionStorage' => 'InoOicServer\\Session\\Storage\\StorageFactory', 'InoOicServer\\ClientRegistryStorage' => 'InoOicServer\\Client\\Registry\\StorageFactory', 'InoOicServer\\ClientRegistry' => 'InoOicServer\\Client\\RegistryFactory', 'InoOicServer\\ServerInfo' => function (ServiceManager $sm) use($smc) {
         $config = $sm->get('Config');
         if (!isset($config[$smc::CONFIG_SERVER_INFO]) || !is_array($config[$smc::CONFIG_SERVER_INFO])) {
             throw new Exception\ConfigNotFoundException($smc::CONFIG_SERVER_INFO);
         }
         $serverInfo = new ServerInfo($config[$smc::CONFIG_SERVER_INFO]);
         return $serverInfo;
     }, 'InoOicServer\\Logger' => function (ServiceManager $sm) use($smc) {
         $config = $sm->get('Config');
         if (!isset($config['oic_server']['logger'])) {
             throw new Exception\ConfigNotFoundException('logger');
         }
         $loggerConfig = $config['oic_server']['logger'];
         if (!isset($loggerConfig['writers'])) {
             throw new Exception\ConfigNotFoundException('logger/writers');
         }
         $logger = new Log\Logger();
         if (count($loggerConfig['writers'])) {
             $priority = 1;
             foreach ($loggerConfig['writers'] as $writerConfig) {
                 $writer = $logger->writerPlugin($writerConfig['name'], $writerConfig['options']);
                 if (isset($writerConfig['filters']) && is_array($writerConfig['filters'])) {
                     foreach ($writerConfig['filters'] as $filterName => $filterValue) {
                         $filterClass = '\\Zend\\Log\\Filter\\' . String::underscoreToCamelCase($filterName);
                         $filter = new $filterClass($filterValue);
                         $writer->addFilter($filter);
                     }
                 }
                 if (isset($writerConfig['formatter']) && is_array($writerConfig['formatter']) && isset($writerConfig['formatter'])) {
                     $formatterConfig = $writerConfig['formatter'];
                     if (isset($formatterConfig['format'])) {
                         $formatter = new Log\Formatter\Simple($formatterConfig['format']);
                         if (isset($formatterConfig['dateTimeFormat'])) {
                             $formatter->setDateTimeFormat($formatterConfig['dateTimeFormat']);
                         }
                         $writer->setFormatter($formatter);
                     }
                 }
                 $logger->addWriter($writer, $priority++);
             }
         }
         return $logger;
     }, 'InoOicServer\\ErrorHandler' => function (ServiceManager $sm) {
         return new ErrorHandler($sm->get('InoOicServer\\Logger'));
     }, 'InoOicServer\\SessionManager' => function (ServiceManager $sm) {
         $sessionManager = new \Zend\Session\SessionManager();
         return $sessionManager;
     }, 'InoOicServer\\SessionContainer' => function (ServiceManager $sm) {
         // $config = $sm->get('Config');
         $sessionManager = $sm->get('InoOicServer\\SessionManager');
         $container = new \Zend\Session\Container('InoOicServer', $sessionManager);
         return $container;
     }, 'InoOicServer\\UserSerializer' => function (ServiceManager $sm) {
         $config = $sm->get('Config');
         if (!isset($config['oic_server']['user_serializer'])) {
             throw new Exception\ConfigNotFoundException('user_serializer');
         }
         return new User\Serializer\Serializer($config['oic_server']['user_serializer']);
     }, 'InoOicServer\\UserFactory' => function (ServiceManager $sm) {
         $config = $sm->get('Config');
         if (!isset($config['oic_server']['user_factory'])) {
             throw new Exception\ConfigNotFoundException('user_factory');
         }
         return new User\UserFactory($config['oic_server']['user_factory']);
     }, 'InoOicServer\\UserDataConnector' => function (ServiceManager $sm) {
         $config = $sm->get('Config');
         if (!isset($config['oic_server']['data_connectors'])) {
             throw new Exception\ConfigNotFoundException('data_connectors');
         }
         $dataConnectorConfigs = $config['oic_server']['data_connectors'];
         $factory = $sm->get('InoOicServer\\UserDataConnectorFactory');
         $chain = $factory->createDataConnector(array('class' => '\\InoOicServer\\User\\DataConnector\\Chain'));
         foreach ($dataConnectorConfigs as $dataConnectorConfig) {
             $chain->addDataConnector($factory->createDataConnector($dataConnectorConfig));
         }
         return $chain;
     }, 'InoOicServer\\UserValidator' => function (ServiceManager $sm) {
         $config = $sm->get('Config');
         $validatorsConfig = array();
         if (isset($config['oic_server']['user_validators']) && is_array($config['oic_server']['user_validators'])) {
             $validatorsConfig = $config['oic_server']['user_validators'];
         }
         /* @var $factory \InoOicServer\User\Validator\ValidatorFactory */
         $factory = $sm->get('InoOicServer\\UserValidatorFactory');
         $validator = $factory->createValidator(array('class' => '\\InoOicServer\\User\\Validator\\ChainValidator'));
         foreach ($validatorsConfig as $validatorConfig) {
             $subValidator = $factory->createValidator($validatorConfig);
             $subValidator->setSessionContainer($sm->get('InoOicServer\\SessionContainer'));
             $validator->addValidator($subValidator);
         }
         return $validator;
     }, 'InoOicServer\\UserInfoMapper' => function (ServiceManager $sm) {
         $config = $sm->get('Config');
         if (!isset($config['oic_server']['user_info_mapper'])) {
             throw new Exception\ConfigNotFoundException('user_info_mapper');
         }
         $mapperConfig = $config['oic_server']['user_info_mapper'];
//.........这里部分代码省略.........
开发者ID:ivan-novakov,项目名称:zf2-openid-connect-server-module,代码行数:101,代码来源:ServiceManagerConfig.php


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