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


PHP LoggerOptionConverter类代码示例

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


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

示例1: setLevelToMatch

 /**
  * @param string $l the level to match
  */
 public function setLevelToMatch($l)
 {
     if ($l instanceof LoggerLevel) {
         $this->levelToMatch = $l;
     } else {
         $this->levelToMatch = LoggerOptionConverter::toLevel($l, null);
     }
 }
开发者ID:dobreapa,项目名称:owasp-esapi-php,代码行数:11,代码来源:LoggerFilterLevelMatch.php

示例2: testToBoolean

 public function testToBoolean()
 {
     self::assertEquals(true, LoggerOptionConverter::toBoolean(null, true));
     self::assertEquals(true, LoggerOptionConverter::toBoolean(null));
     self::assertEquals(true, LoggerOptionConverter::toBoolean(true));
     self::assertEquals(true, LoggerOptionConverter::toBoolean("1"));
     self::assertEquals(true, LoggerOptionConverter::toBoolean("true"));
     self::assertEquals(true, LoggerOptionConverter::toBoolean("on"));
     self::assertEquals(true, LoggerOptionConverter::toBoolean("yes"));
     self::assertEquals(false, LoggerOptionConverter::toBoolean(null, false));
     self::assertEquals(false, LoggerOptionConverter::toBoolean(false));
     self::assertEquals(false, LoggerOptionConverter::toBoolean(""));
     self::assertEquals(false, LoggerOptionConverter::toBoolean("0"));
     self::assertEquals(false, LoggerOptionConverter::toBoolean("false"));
     self::assertEquals(false, LoggerOptionConverter::toBoolean("off"));
     self::assertEquals(false, LoggerOptionConverter::toBoolean("no"));
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:17,代码来源:LoggerOptionConverterTest.php

示例3: setProperties

 public function setProperties($properties, $prefix)
 {
     $len = strlen($prefix);
     while (list($key, ) = each($properties)) {
         if (strpos($key, $prefix) === 0) {
             if (strpos($key, '.', $len + 1) > 0) {
                 continue;
             }
             $value = LoggerOptionConverter::findAndSubst($key, $properties);
             $key = substr($key, $len);
             if ($key == 'layout' and $this->obj instanceof LoggerAppender) {
                 continue;
             }
             $this->setProperty($key, $value);
         }
     }
     $this->activate();
 }
开发者ID:BGCX067,项目名称:ezboss-svn-to-git,代码行数:18,代码来源:LoggerReflectionUtils.php

示例4: parseAppender

 /**
  * @param array $props array of properties
  * @param string $appenderName
  * @return LoggerAppender
  */
 private function parseAppender($props, $appenderName)
 {
     $appender = LoggerAppenderPool::getAppenderFromPool($appenderName);
     $prefix = self::APPENDER_PREFIX . $appenderName;
     if ($appender === null) {
         // Appender was not previously initialized.
         $appenderClass = @$props[$prefix];
         $appender = LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderClass);
         if ($appender === null) {
             return null;
         }
     }
     if ($appender->requiresLayout()) {
         $layoutPrefix = $prefix . ".layout";
         $layoutClass = @$props[$layoutPrefix];
         $layoutClass = LoggerOptionConverter::substVars($layoutClass, $props);
         if (empty($layoutClass)) {
             $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple');
         } else {
             $layout = LoggerReflectionUtils::createObject($layoutClass);
             if ($layout === null) {
                 $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple');
             }
         }
         LoggerReflectionUtils::setPropertiesByObject($layout, $props, $layoutPrefix . ".");
         $appender->setLayout($layout);
     }
     LoggerReflectionUtils::setPropertiesByObject($appender, $props, $prefix . ".");
     return $appender;
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:35,代码来源:LoggerConfiguratorIni.php

示例5: setThreshold

 /**
  * Set the threshold level of this appender.
  *
  * @param mixed $threshold can be a {@link LoggerLevel} object or a string.
  * @see LoggerOptionConverter::toLevel()
  */
 function setThreshold($threshold)
 {
     if (is_string($threshold)) {
         $this->threshold = LoggerOptionConverter::toLevel($threshold, null);
     } elseif (is_a($threshold, 'loggerlevel')) {
         $this->threshold = $threshold;
     }
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:14,代码来源:LoggerAppenderSkeleton.php

示例6:

 /**
  * @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

示例7: substVars

 public static function substVars($val, $props = null)
 {
     $sbuf = '';
     $i = 0;
     while (true) {
         $j = strpos($val, self::DELIM_START, $i);
         if ($j === false) {
             // no more variables
             if ($i == 0) {
                 // this is a simple string
                 return $val;
             } else {
                 // add the tail string which contails no variables and return the result.
                 $sbuf .= substr($val, $i);
                 return $sbuf;
             }
         } else {
             $sbuf .= substr($val, $i, $j - $i);
             $k = strpos($val, self::DELIM_STOP, $j);
             if ($k === false) {
                 // LoggerOptionConverter::substVars() has no closing brace. Opening brace
                 return '';
             } else {
                 $j += self::DELIM_START_LEN;
                 $key = substr($val, $j, $k - $j);
                 // first try in System properties
                 $replacement = LoggerOptionConverter::getSystemProperty($key, null);
                 // then try props parameter
                 if ($replacement == null and $props !== null) {
                     $replacement = @$props[$key];
                 }
                 if (!empty($replacement)) {
                     // Do variable substitution on the replacement string
                     // such that we can solve "Hello ${x2}" as "Hello p1"
                     // the where the properties are
                     // x1=p1
                     // x2=${x1}
                     $recursiveReplacement = LoggerOptionConverter::substVars($replacement, $props);
                     $sbuf .= $recursiveReplacement;
                 }
                 $i = $k + self::DELIM_STOP_LEN;
             }
         }
     }
 }
开发者ID:haitao1880,项目名称:study,代码行数:45,代码来源:LoggerOptionConverter.php

示例8: setLevelMax

 /**
  * @param string $l the level max to match
  */
 function setLevelMax($l)
 {
     $this->levelMax = LoggerOptionConverter::toLevel($l, null);
 }
开发者ID:ruckfull,项目名称:taobaocrm,代码行数:7,代码来源:LoggerLevelRangeFilter.php

示例9: setProperties

 /**
  * Set the properites for the object that match the
  * <code>prefix</code> passed as parameter.
  *
  * @param array $properties An array containing keys and values.
  * @param string $prefix Only keys having the specified prefix will be set.
  */
 function setProperties($properties, $prefix)
 {
     LoggerLog::debug("LoggerOptionConverter::setProperties():prefix=[{$prefix}]");
     $len = strlen($prefix);
     while (list($key, ) = each($properties)) {
         if (strpos($key, $prefix) === 0) {
             if (strpos($key, '.', $len + 1) > 0) {
                 continue;
             }
             $value = LoggerOptionConverter::findAndSubst($key, $properties);
             $key = substr($key, $len);
             if ($key == 'layout' && is_a($this->obj, 'loggerappender')) {
                 continue;
             }
             $this->setProperty($key, $value);
         }
     }
     $this->activate();
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:26,代码来源:LoggerPropertySetter.php

示例10: setContextPrinting

 /**
  * The <b>ContextPrinting</b> option specifies log output will include
  * the nested context information belonging to the current thread.
  * This is true by default.
  */
 public function setContextPrinting($contextPrinting)
 {
     $this->contextPrinting = LoggerOptionConverter::toBoolean($contextPrinting);
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:9,代码来源:LoggerLayoutTTCC.php

示例11: setHtmlLineBreaks

 public function setHtmlLineBreaks($value)
 {
     $this->htmlLineBreaks = LoggerOptionConverter::toBoolean($value, false);
 }
开发者ID:haitao1880,项目名称:study,代码行数:4,代码来源:LoggerAppenderEcho.php

示例12: testSubstituteVars

 public function testSubstituteVars()
 {
     $props['OTHER_CONSTANT'] = "OTHER";
     $props['MY_CONSTANT'] = "TEST";
     $props['NEXT_CONSTANT'] = "NEXT";
     $result = LoggerOptionConverter::substVars('Value of key is ${MY_CONSTANT}.', $props);
     self::assertEquals('Value of key is TEST.', $result);
     $result = LoggerOptionConverter::substVars('Value of key is ${MY_CONSTANT} or ${OTHER_CONSTANT}.', $props);
     self::assertEquals('Value of key is TEST or OTHER.', $result);
     $result = LoggerOptionConverter::substVars('Value of key is ${MY_CONSTANT_CONSTANT}.', $props);
     self::assertEquals('Value of key is DEFINE.', $result);
     $result = LoggerOptionConverter::substVars('Value of key is ${MY_CONSTANT_CONSTANT} or ${MY_CONSTANT_CONSTANT_OTHER}.', $props);
     self::assertEquals('Value of key is DEFINE or DEFINE_OTHER.', $result);
 }
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:14,代码来源:LoggerOptionConverterTest.php

示例13: doConfigure

 private function doConfigure($url, LoggerHierarchy $hierarchy)
 {
     $config = (require $url);
     // set threshold
     if (isset($config['threshold'])) {
         $hierarchy->setThreshold(LoggerOptionConverter::toLevel($config['threshold'], LoggerLevel::getLevelAll()));
     }
     // parse and create appenders
     if (isset($config['appenders'])) {
         foreach ($config['appenders'] as $appenderName => $appenderProperties) {
             $appender = LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderProperties['class']);
             if ($appender->requiresLayout()) {
                 if (isset($appenderProperties['layout'])) {
                     if (isset($appenderProperties['layout']['class']) and !empty($appenderProperties['layout']['class'])) {
                         $layoutClass = $appenderProperties['layout']['class'];
                     } else {
                         $layoutClass = 'LoggerLayoutSimple';
                     }
                     $layout = LoggerReflectionUtils::createObject($layoutClass);
                     if ($layout === null) {
                         $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple');
                     }
                     if ($layout instanceof LoggerLayoutPattern) {
                         $layout->setConversionPattern($appenderProperties['layout']['conversionPattern']);
                     }
                     $appender->setLayout($layout);
                 } else {
                     // TODO: throw exception?
                 }
             }
         }
     }
     // parse and create root logger
     if (isset($config['rootLogger'])) {
         $rootLogger = $hierarchy->getRootLogger();
         if (isset($config['rootLogger']['level'])) {
             $rootLogger->setLevel(LoggerOptionConverter::toLevel($config['rootLogger']['level'], LoggerLevel::getLevelDebug()));
             if (isset($config['rootLogger']['appenders'])) {
                 foreach ($config['rootLogger']['appenders'] as $appenderName) {
                     $appender = LoggerAppenderPool::getAppenderFromPool($appenderName);
                     if ($appender !== null) {
                         $rootLogger->addAppender($appender);
                     }
                 }
             }
         }
     }
     // parse and create loggers
     if (isset($config['loggers'])) {
         foreach ($config['loggers'] as $loggerName => $loggerProperties) {
             if (is_string($loggerName)) {
                 $logger = $hierarchy->getLogger($loggerName);
                 if (isset($loggerProperties['level'])) {
                     $logger->setLevel(LoggerOptionConverter::toLevel($loggerProperties['level'], LoggerLevel::getLevelDebug()));
                     if (isset($loggerProperties['appenders'])) {
                         foreach ($loggerProperties['appenders'] as $appenderName) {
                             $appender = LoggerAppenderPool::getAppenderFromPool($appenderName);
                             if ($appender !== null) {
                                 $logger->addAppender($appender);
                             }
                         }
                     }
                 }
             } else {
                 // TODO: throw exception
             }
         }
     }
     return true;
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:70,代码来源:LoggerConfiguratorPhp.php

示例14: doConfigure

 private function doConfigure($url, LoggerHierarchy $hierarchy)
 {
     if (!is_array($url)) {
         $config = (require $url);
     } else {
         $config = $url;
     }
     // set threshold
     if (isset($config['threshold'])) {
         $hierarchy->setThreshold(LoggerOptionConverter::toLevel($config['threshold'], LoggerLevel::getLevelAll()));
     }
     // add renderes
     if (isset($config['renderers'])) {
         foreach ($config['renderers'] as $renderedClass => $renderingClass) {
             $hierarchy->getRendererMap()->addRenderer($renderedClass, $renderingClass);
         }
     }
     // parse and create appenders
     if (isset($config['appenders'])) {
         foreach ($config['appenders'] as $appenderName => $appenderProperties) {
             $appender = LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderProperties['class']);
             // unset so that the property wont be drawn up again
             unset($appenderProperties['class']);
             if ($appender->requiresLayout()) {
                 if (isset($appenderProperties['layout'])) {
                     if (isset($appenderProperties['layout']['class']) and !empty($appenderProperties['layout']['class'])) {
                         $layoutClass = $appenderProperties['layout']['class'];
                     } else {
                         $layoutClass = 'LoggerLayoutSimple';
                     }
                     $layout = LoggerReflectionUtils::createObject($layoutClass);
                     if ($layout === null) {
                         $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple');
                     }
                     if (isset($appenderProperties['file']) && method_exists($appender, 'setFileName')) {
                         $appender->setFile($appenderProperties['file'], true);
                     }
                     if ($layout instanceof LoggerLayoutPattern) {
                         $layout->setConversionPattern($appenderProperties['layout']['conversionPattern']);
                     }
                     $appender->setLayout($layout);
                     // unset so that the property wont be drawn up again
                     unset($appenderProperties['layout']);
                 } else {
                     // TODO: throw exception?
                 }
             }
             // set remaining properties and activate appender
             $setter = new LoggerReflectionUtils($appender);
             foreach ($appenderProperties as $key => $val) {
                 $setter->setProperty($key, $val);
             }
             $setter->activate();
         }
     }
     // parse and create root logger
     if (isset($config['rootLogger'])) {
         $rootLogger = $hierarchy->getRootLogger();
         if (isset($config['rootLogger']['level'])) {
             $rootLogger->setLevel(LoggerOptionConverter::toLevel($config['rootLogger']['level'], LoggerLevel::getLevelDebug()));
             if (isset($config['rootLogger']['appenders'])) {
                 foreach ($config['rootLogger']['appenders'] as $appenderName) {
                     $appender = LoggerAppenderPool::getAppenderFromPool($appenderName);
                     if ($appender !== null) {
                         $rootLogger->addAppender($appender);
                     }
                 }
             }
         }
     }
     // parse and create loggers
     if (isset($config['loggers'])) {
         foreach ($config['loggers'] as $loggerName => $loggerProperties) {
             if (is_string($loggerName)) {
                 $logger = $hierarchy->getLogger($loggerName);
                 if (isset($loggerProperties['level'])) {
                     $logger->setLevel(LoggerOptionConverter::toLevel($loggerProperties['level'], LoggerLevel::getLevelDebug()));
                     if (isset($loggerProperties['appenders'])) {
                         foreach ($loggerProperties['appenders'] as $appenderName) {
                             $appender = LoggerAppenderPool::getAppenderFromPool($appenderName);
                             if ($appender !== null) {
                                 $logger->addAppender($appender);
                             }
                         }
                     }
                 }
             } else {
                 // TODO: throw exception
             }
         }
     }
     return true;
 }
开发者ID:haitao1880,项目名称:study,代码行数:93,代码来源:LoggerConfiguratorPhp.php

示例15: setCreateTable

 function setCreateTable($flag)
 {
     $this->createTable = LoggerOptionConverter::toBoolean($flag, true);
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:4,代码来源:LoggerAppenderDb.php


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