コード例 #1
0
 /**
  * For statsd, we use a different logic than for other loggers:
  * in the name of the KPI we embed some variable data, such as f.e.
  * content-class name. This allows better grouping and filtering of data
  * in the Graphite console.
  *
  * @see ezperformancelogger.ini
  *
  * We cache internally prefix and postfix for optimal performances
  */
 public static function transformVarName($var, $default = null)
 {
     if (self::$prefix === null || self::$postfix === null) {
         $strip = eZPerfLoggerINI::variable('StatsdSettings', 'RemoveEmptyTokensInVariable') == 'enabled';
         foreach (array(eZPerfLoggerINI::variable('StatsdSettings', 'VariablePrefix'), eZPerfLoggerINI::variable('StatsdSettings', 'VariablePostfix')) as $i => $string) {
             if (strpos($string, '$') !== false) {
                 $tokens = explode('.', $string);
                 foreach ($tokens as $j => &$token) {
                     if (strlen($token) && $token[0] == '$') {
                         $token = str_replace('.', '_', eZPerfLogger::getModuleData(substr($token, 1), $default));
                         if ($strip && $token == '') {
                             unset($tokens[$j]);
                         }
                     }
                 }
                 $string = implode('.', $tokens);
             }
             if ($i) {
                 self::$postfix = $string;
             } else {
                 self::$prefix = $string;
             }
         }
     }
     return self::$prefix . $var . self::$postfix;
 }