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


PHP LoggerOptionConverter::substVars方法代码示例

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


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

示例1:

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

示例2: 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

示例3: subst

 private function subst($value)
 {
     return LoggerOptionConverter::substVars($value);
 }
开发者ID:indra012patel,项目名称:gventure_framework,代码行数:4,代码来源:LoggerConfiguratorXml.php

示例4: substVars

 /**
  * Perform variable substitution in string <var>$val</var> from the
  * values of keys found with the {@link getSystemProperty()} method.
  * 
  * <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
  * 
  * <p>For example, if the "MY_CONSTANT" contains "value", then
  * the call
  * <code>
  * $s = LoggerOptionConverter::substituteVars("Value of key is ${MY_CONSTANT}.");
  * </code>
  * will set the variable <i>$s</i> to "Value of key is value.".</p>
  * 
  * <p>If no value could be found for the specified key, then the
  * <var>$props</var> parameter is searched, if the value could not
  * be found there, then substitution defaults to the empty string.</p>
  * 
  * <p>For example, if {@link getSystemProperty()} cannot find any value for the key
  * "inexistentKey", then the call
  * <code>
  * $s = LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]");
  * </code>
  * will set <var>$s</var> to "Value of inexistentKey is []".</p>
  * 
  * <p>A warn is thrown if <var>$val</var> contains a start delimeter "${" 
  * which is not balanced by a stop delimeter "}" and an empty string is returned.</p>
  * 
  * @log4j-author Avy Sharell
  * 
  * @param string $val The string on which variable substitution is performed.
  * @param array $props
  * @return string
  *
  * @static
  */
 function substVars($val, $props = null)
 {
     LoggerLog::debug("LoggerOptionConverter::substVars():val=[{$val}]");
     $sbuf = '';
     $i = 0;
     while (true) {
         $j = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_START, $i);
         if ($j === false) {
             LoggerLog::debug("LoggerOptionConverter::substVars() no more variables");
             // no more variables
             if ($i == 0) {
                 // this is a simple string
                 LoggerLog::debug("LoggerOptionConverter::substVars() simple string");
                 return $val;
             } else {
                 // add the tail string which contails no variables and return the result.
                 $sbuf .= substr($val, $i);
                 LoggerLog::debug("LoggerOptionConverter::substVars():sbuf=[{$sbuf}]. Returning sbuf");
                 return $sbuf;
             }
         } else {
             $sbuf .= substr($val, $i, $j - $i);
             LoggerLog::debug("LoggerOptionConverter::substVars():sbuf=[{$sbuf}]:i={$i}:j={$j}.");
             $k = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_STOP, $j);
             if ($k === false) {
                 LoggerLog::warn("LoggerOptionConverter::substVars() " . "'{$val}' has no closing brace. Opening brace at position {$j}.");
                 return '';
             } else {
                 $j += LOG4PHP_OPTION_CONVERTER_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 + LOG4PHP_OPTION_CONVERTER_DELIM_STOP_LEN;
             }
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:85,代码来源:LoggerOptionConverter.php

示例5: 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

示例6: 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


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