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


PHP LoggerAppender::singleton方法代码示例

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


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

示例1: configure

 /**
  * Add a {@link LoggerAppenderConsole} that uses 
  * the {@link LoggerLayoutTTCC} to the root category.
  * 
  * @param string $url not used here
  * @static  
  */
 function configure($url = null)
 {
     $root =& LoggerManager::getRootLogger();
     $appender =& LoggerAppender::singleton('A1', 'LoggerAppenderConsole');
     $layout = LoggerLayout::factory('LoggerLayoutTTCC');
     $appender->setLayout($layout);
     $root->addAppender($appender);
 }
开发者ID:roni5,项目名称:sela,代码行数:15,代码来源:LoggerBasicConfigurator.php

示例2:

 /**
  * @param array $props array of properties
  * @param string $appenderName
  * @return LoggerAppender
  */
 function &parseAppender($props, $appenderName)
 {
     $appender =& LoggerAppender::singleton($appenderName);
     if ($appender !== null) {
         LoggerLog::debug("LoggerPropertyConfigurator::parseAppender() " . "Appender [{$appenderName}] was already parsed.");
         return $appender;
     }
     // Appender was not previously initialized.
     $prefix = LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_APPENDER_PREFIX . $appenderName;
     $layoutPrefix = $prefix . ".layout";
     $appenderClass = @$props[$prefix];
     if (!empty($appenderClass)) {
         $appender =& LoggerAppender::singleton($appenderName, $appenderClass);
         if ($appender === null) {
             LoggerLog::warn("LoggerPropertyConfigurator::parseAppender() " . "Could not instantiate appender named [{$appenderName}].");
             return null;
         }
     } else {
         LoggerLog::warn("LoggerPropertyConfigurator::parseAppender() " . "Could not instantiate appender named [{$appenderName}] with null className.");
         return null;
     }
     $appender->setName($appenderName);
     if ($appender->requiresLayout()) {
         LoggerLog::debug("LoggerPropertyConfigurator::parseAppender() " . "Parsing layout section for [{$appenderName}].");
         $layoutClass = @$props[$layoutPrefix];
         $layoutClass = LoggerOptionConverter::substVars($layoutClass, $props);
         if (empty($layoutClass)) {
             LoggerLog::warn("LoggerPropertyConfigurator::parseAppender() " . "layout class is empty in '{$layoutPrefix}'. Using Simple layout");
             $layout = LoggerLayout::factory('LoggerLayoutSimple');
         } else {
             $layout = LoggerLayout::factory($layoutClass);
             if ($layout === null) {
                 LoggerLog::warn("LoggerPropertyConfigurator::parseAppender() " . "cannot create layout '{$layoutClass}'. Using Simple layout");
                 $layout = LoggerLayout::factory('LoggerLayoutSimple');
             }
         }
         LoggerLog::debug("LoggerPropertyConfigurator::parseAppender() " . "Parsing layout options for [{$appenderName}].");
         LoggerPropertySetter::setPropertiesByObject($layout, $props, $layoutPrefix . ".");
         LoggerLog::debug("LoggerPropertyConfigurator::parseAppender() " . "End Parsing layout options for [{$appenderName}].");
         $appender->setLayout($layout);
     }
     LoggerPropertySetter::setPropertiesByObject($appender, $props, $prefix . ".");
     LoggerLog::debug("LoggerPropertyConfigurator::parseAppender() " . "Parsed [{$appenderName}] options.");
     return $appender;
 }
开发者ID:ruckfull,项目名称:taobaocrm,代码行数:50,代码来源:LoggerPropertyConfigurator.php

示例3: tagOpen

 /**
  * @param mixed $parser
  * @param string $tag
  * @param array $attribs
  *
  * @todo In 'LOGGER' case find a better way to detect 'getLogger()' method
  */
 function tagOpen($parser, $tag, $attribs)
 {
     switch ($tag) {
         case 'CONFIGURATION':
         case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS . ':CONFIGURATION':
             LoggerLog::debug("LoggerDOMConfigurator::tagOpen() CONFIGURATION");
             if (isset($attribs['THRESHOLD'])) {
                 $this->repository->setThreshold(LoggerOptionConverter::toLevel($this->subst($attribs['THRESHOLD']), $this->repository->getThreshold()));
             }
             if (isset($attribs['DEBUG'])) {
                 $debug = LoggerOptionConverter::toBoolean($this->subst($attribs['DEBUG']), LoggerLog::internalDebugging());
                 $this->repository->debug = $debug;
                 LoggerLog::internalDebugging($debug);
                 LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LOG4PHP:CONFIGURATION. Internal Debug turned " . ($debug ? 'on' : 'off'));
             }
             break;
         case 'APPENDER':
         case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS . ':APPENDER':
             unset($this->appender);
             $this->appender = null;
             $name = $this->subst(@$attribs['NAME']);
             $class = $this->subst(@$attribs['CLASS']);
             LoggerLog::debug("LoggerDOMConfigurator::tagOpen():tag=[{$tag}]:name=[{$name}]:class=[{$class}]");
             $this->appender =& LoggerAppender::singleton($name, $class);
             if ($this->appender === null) {
                 LoggerLog::warn("LoggerDOMConfigurator::tagOpen() APPENDER cannot instantiate appender '{$name}'");
             }
             $this->state[] = LOG4PHP_LOGGER_DOM_CONFIGURATOR_APPENDER_STATE;
             break;
         case 'APPENDER_REF':
         case 'APPENDER-REF':
         case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS . ':APPENDER_REF':
         case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS . ':APPENDER-REF':
             if (isset($attribs['REF']) and !empty($attribs['REF'])) {
                 $appenderName = $this->subst($attribs['REF']);
                 LoggerLog::debug("LoggerDOMConfigurator::tagOpen() APPENDER-REF ref='{$appenderName}'");
                 $appender =& LoggerAppender::singleton($appenderName);
                 if ($appender !== null) {
                     switch (end($this->state)) {
                         case LOG4PHP_LOGGER_DOM_CONFIGURATOR_LOGGER_STATE:
                         case LOG4PHP_LOGGER_DOM_CONFIGURATOR_ROOT_STATE:
                             $this->logger->addAppender($appender);
                             break;
                     }
                 } else {
                     LoggerLog::warn("LoggerDOMConfigurator::tagOpen() APPENDER-REF ref '{$appenderName}' points to a null appender");
                 }
             } else {
                 LoggerLog::warn("LoggerDOMConfigurator::tagOpen() APPENDER-REF ref not set or empty");
             }
             break;
         case 'FILTER':
         case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS . ':FILTER':
             LoggerLog::debug("LoggerDOMConfigurator::tagOpen() FILTER");
             unset($this->filter);
             $this->filter = null;
             $filterName = basename($this->subst(@$attribs['CLASS']));
             if (!empty($filterName)) {
                 if (!class_exists($filterName)) {
                     @(include_once LOG4PHP_DIR . "/varia/{$filterName}.php");
                 }
                 if (class_exists($filterName)) {
                     $this->filter = new $filterName();
                 } else {
                     LoggerLog::warn("LoggerDOMConfigurator::tagOpen() FILTER. class '{$filterName}' doesnt exist");
                 }
                 $this->state[] = LOG4PHP_LOGGER_DOM_CONFIGURATOR_FILTER_STATE;
             } else {
                 LoggerLog::warn("LoggerDOMConfigurator::tagOpen() FILTER filter name cannot be empty");
             }
             break;
         case 'LAYOUT':
         case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS . ':LAYOUT':
             $class = @$attribs['CLASS'];
             LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LAYOUT class='{$class}'");
             $this->layout = LoggerLayout::factory($this->subst($class));
             if ($this->layout === null) {
                 LoggerLog::warn("LoggerDOMConfigurator::tagOpen() LAYOUT unable to instanciate class='{$class}'");
             }
             $this->state[] = LOG4PHP_LOGGER_DOM_CONFIGURATOR_LAYOUT_STATE;
             break;
         case 'LOGGER':
         case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS . ':LOGGER':
             // $this->logger is assigned by reference.
             // Only '$this->logger=null;' destroys referenced object
             unset($this->logger);
             $this->logger = null;
             $loggerName = $this->subst(@$attribs['NAME']);
             if (!empty($loggerName)) {
                 LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LOGGER. name='{$loggerName}'");
                 $class = $this->subst(@$attribs['CLASS']);
                 if (empty($class)) {
                     $this->logger =& $this->repository->getLogger($loggerName);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:101,代码来源:LoggerDOMConfigurator.php


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