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


PHP LoggerLevel::toLevel方法代码示例

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


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

示例1: log

 /**
  * Logs with an arbitrary level.
  *
  * @param mixed $level
  * @param mixed $message
  * @param mixed[] $context
  * @return null
  */
 public function log($level, $message, array $context = array())
 {
     if (!array_key_exists($level, $this->levels)) {
         $level = $this->defaultLevel;
     }
     $level = \LoggerLevel::toLevel($this->levels[$level], $this->defaultLevel);
     $message = $this->formatter->format($level, $message, $context);
     $this->logger->log($level, $message);
 }
开发者ID:abacaphiliac,项目名称:psr-log4php,代码行数:17,代码来源:LoggerWrapper.php

示例2: testLevelAll

 public function testLevelAll()
 {
     $this->doTestLevel(LoggerLevel::getLevelAll(), LoggerLevel::ALL, 'ALL', 7);
     $this->doTestLevel(LoggerLevel::toLevel(LoggerLevel::ALL), LoggerLevel::ALL, 'ALL', 7);
     $this->doTestLevel(LoggerLevel::toLevel('ALL'), LoggerLevel::ALL, 'ALL', 7);
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:6,代码来源:LoggerLevelTest.php

示例3: usage

    }
    // --driver
    if (preg_match('/--dbdriver=(.*)/', $argv[$i], $matches)) {
        $options['core']['dbdriver'] = $matches[1];
    }
    //--ignore-preup
    if (preg_match('/--ignore-preup/', $argv[$i], $matches)) {
        $options['core']['ignore_preup'] = true;
    }
    //--force
    if (preg_match('/--force/', $argv[$i], $matches)) {
        $options['core']['force'] = true;
    }
    // --level
    if (preg_match('/--verbose=(.*)/', $argv[$i], $matches)) {
        $options['core']['verbose'] = LoggerLevel::toLevel($matches[1], 'INFO');
    }
    // --bucket
    if (preg_match('/--bucket=(.*)/', $argv[$i], $matches)) {
        $options['core']['bucket'] = $matches[1];
    }
}
if ($func == 'help') {
    usage();
    exit;
}
if (!isset($options['core']['verbose'])) {
    $options['core']['verbose'] = 'INFO';
}
// Get the DB connexion
// First try the file
开发者ID:pombredanne,项目名称:ForgeUpgrade,代码行数:31,代码来源:forgeupgrade.php

示例4: toLevel

 /**
  * Converts a standard or custom priority level to a Level
  * object.
  *
  * <p> If <var>$value</var> is of form "<b>level#full_file_classname</b>",
  * where <i>full_file_classname</i> means the class filename with path
  * but without php extension, then the specified class' <i>toLevel()</i> method
  * is called to process the specified level string; if no '#'
  * character is present, then the default {@link LoggerLevel}
  * class is used to process the level value.</p>
  *
  * <p>As a special case, if the <var>$value</var> parameter is
  * equal to the string "NULL", then the value <i>null</i> will
  * be returned.</p>
  *
  * <p>If any error occurs while converting the value to a level,
  * the <var>$defaultValue</var> parameter, which may be
  * <i>null</i>, is returned.</p>
  *
  * <p>Case of <var>$value</var> is insignificant for the level level, but is
  * significant for the class name part, if present.</p>
  *
  * @param string $value
  * @param LoggerLevel $defaultValue
  * @return LoggerLevel a {@link LoggerLevel} or null
  * @static
  */
 public static function toLevel($value, $defaultValue)
 {
     if ($value === null) {
         return $defaultValue;
     }
     $hashIndex = strpos($value, '#');
     if ($hashIndex === false) {
         if ("NULL" == strtoupper($value)) {
             return null;
         } else {
             // no class name specified : use standard Level class
             return LoggerLevel::toLevel($value, $defaultValue);
         }
     }
     $result = $defaultValue;
     $clazz = substr($value, $hashIndex + 1);
     $levelName = substr($value, 0, $hashIndex);
     // This is degenerate case but you never know.
     if ("NULL" == strtoupper($levelName)) {
         return null;
     }
     $clazz = basename($clazz);
     if (class_exists($clazz)) {
         $result = @call_user_func(array($clazz, 'toLevel'), $levelName, $defaultValue);
         if (!$result instanceof LoggerLevel) {
             $result = $defaultValue;
         }
     }
     return $result;
 }
开发者ID:haitao1880,项目名称:study,代码行数:57,代码来源:LoggerOptionConverter.php

示例5: createEvent

 private function createEvent($message, $level)
 {
     $eventMock = new LoggerLoggingEvent("LoggerAppenderFirePHPTest", new Logger("TEST"), LoggerLevel::toLevel($level), $message);
     return $eventMock;
 }
开发者ID:mc5827,项目名称:Padosi,代码行数:5,代码来源:LoggerAppenderFirephpTest.php

示例6: toLevel

 /**
  * Converts a standard or custom priority level to a Level
  * object.
  *
  * <p> If <var>$value</var> is of form "<b>level#full_file_classname</b>",
  * where <i>full_file_classname</i> means the class filename with path
  * but without php extension, then the specified class' <i>toLevel()</i> method
  * is called to process the specified level string; if no '#'
  * character is present, then the default {@link LoggerLevel}
  * class is used to process the level value.</p>
  *
  * <p>As a special case, if the <var>$value</var> parameter is
  * equal to the string "NULL", then the value <i>null</i> will
  * be returned.</p>
  *
  * <p>If any error occurs while converting the value to a level,
  * the <var>$defaultValue</var> parameter, which may be
  * <i>null</i>, is returned.</p>
  *
  * <p>Case of <var>$value</var> is insignificant for the level level, but is
  * significant for the class name part, if present.</p>
  *
  * @param string $value
  * @param LoggerLevel $defaultValue
  * @return LoggerLevel a {@link LoggerLevel} or null
  * @static
  */
 function toLevel($value, $defaultValue)
 {
     if ($value === null) {
         return $defaultValue;
     }
     $hashIndex = strpos($value, '#');
     if ($hashIndex === false) {
         if ("NULL" == strtoupper($value)) {
             return null;
         } else {
             // no class name specified : use standard Level class
             return LoggerLevel::toLevel($value, $defaultValue);
         }
     }
     $result = $defaultValue;
     $clazz = substr($value, $hashIndex + 1);
     $levelName = substr($value, 0, $hashIndex);
     // This is degenerate case but you never know.
     if ("NULL" == strtoupper($levelName)) {
         return null;
     }
     LoggerLog::debug("LoggerOptionConverter::toLevel():class=[{$clazz}]:pri=[{$levelName}]");
     if (!class_exists($clazz)) {
         @(include_once "{$clazz}.php");
     }
     $clazz = basename($clazz);
     if (class_exists($clazz)) {
         $result = @call_user_func(array($clazz, 'toLevel'), $value, $defaultValue);
         if (!is_a($result, 'loggerlevel')) {
             LoggerLog::debug("LoggerOptionConverter::toLevel():class=[{$clazz}] cannot call toLevel(). Returning default.");
             $result = $defaultValue;
         }
     } else {
         LoggerLog::warn("LoggerOptionConverter::toLevel() class '{$clazz}' doesnt exists.");
     }
     return $result;
 }
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:64,代码来源:LoggerOptionConverter.php

示例7: switch

 /**
  * Convert the string passed as argument to a level. If the
  * conversion fails, then this method returns a DEBUG Level.
  *
  * @param mixed $arg
  * @param LoggerLevel $default
  * @static 
  */
 function &toLevel($arg, $defaultLevel = null)
 {
     if ($defaultLevel === null) {
         return LoggerLevel::toLevel($arg, LoggerLevel::getLevelDebug());
     } else {
         if (is_int($arg)) {
             switch ($arg) {
                 case LOG4PHP_LEVEL_ALL_INT:
                     return LoggerLevel::getLevelAll();
                 case LOG4PHP_LEVEL_DEBUG_INT:
                     return LoggerLevel::getLevelDebug();
                 case LOG4PHP_LEVEL_INFO_INT:
                     return LoggerLevel::getLevelInfo();
                 case LOG4PHP_LEVEL_WARN_INT:
                     return LoggerLevel::getLevelWarn();
                 case LOG4PHP_LEVEL_ERROR_INT:
                     return LoggerLevel::getLevelError();
                 case LOG4PHP_LEVEL_FATAL_INT:
                     return LoggerLevel::getLevelFatal();
                 case LOG4PHP_LEVEL_OFF_INT:
                     return LoggerLevel::getLevelOff();
                 default:
                     return $defaultLevel;
             }
         } else {
             switch (strtoupper($arg)) {
                 case 'ALL':
                     return LoggerLevel::getLevelAll();
                 case 'DEBUG':
                     return LoggerLevel::getLevelDebug();
                 case 'INFO':
                     return LoggerLevel::getLevelInfo();
                 case 'WARN':
                     return LoggerLevel::getLevelWarn();
                 case 'ERROR':
                     return LoggerLevel::getLevelError();
                 case 'FATAL':
                     return LoggerLevel::getLevelFatal();
                 case 'OFF':
                     return LoggerLevel::getLevelOff();
                 default:
                     return $defaultLevel;
             }
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:54,代码来源:LoggerLevel.php

示例8: configureLogger

 /**
  * Configures a logger. 
  * 
  * @param Logger $logger The logger to configure
  * @param array $config Logger configuration options.
  */
 private function configureLogger(Logger $logger, $config)
 {
     $loggerName = $logger->getName();
     // Set logger level
     if (isset($config['level'])) {
         $level = LoggerLevel::toLevel($config['level']);
         if (isset($level)) {
             $logger->setLevel($level);
         } else {
             $default = $logger->getLevel();
             $this->warn("Invalid level value [{$config['level']}] specified for logger [{$loggerName}]. Ignoring level definition.");
         }
     }
     // Link appenders to logger
     if (isset($config['appenders'])) {
         foreach ($config['appenders'] as $appenderName) {
             if (isset($this->appenders[$appenderName])) {
                 $logger->addAppender($this->appenders[$appenderName]);
             } else {
                 $this->warn("Nonexistnant appender [{$appenderName}] linked to logger [{$loggerName}].");
             }
         }
     }
     // Set logger additivity
     if (isset($config['additivity'])) {
         $additivity = LoggerOptionConverter::toBoolean($config['additivity'], null);
         if (is_bool($additivity)) {
             $logger->setAdditivity($additivity);
         } else {
             $this->warn("Invalid additivity value [{$config['additivity']}] specified for logger [{$loggerName}]. Ignoring additivity setting.");
         }
     }
 }
开发者ID:NetworkCedu,项目名称:saigon,代码行数:39,代码来源:LoggerConfiguratorDefault.php

示例9: toLevelEx

 /** Converts the value to a level. Throws an exception if not possible. */
 public static function toLevelEx($value)
 {
     if ($value instanceof LoggerLevel) {
         return $value;
     }
     $level = LoggerLevel::toLevel($value);
     if ($level === null) {
         throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a logger level.");
     }
     return $level;
 }
开发者ID:RobertWang,项目名称:sabre-zarafa,代码行数:12,代码来源:LoggerOptionConverter.php

示例10: getLogger

<?php

require_once BASE_PATH . "/lib/log/log4php/Logger.php";
$log = Logger::getRootLogger();
$log->setLevel(LoggerLevel::toLevel(AE_LOG_LEVEL));
$appender = new LoggerAppenderRollingFile("MyAppender");
$appender->setFile(BASE_PATH . "/log/tephlon.log", true);
$appender->setMaxBackupIndex(10);
$appender->setMaxFileSize("10MB");
$appenderlayout = new LoggerLayoutPattern();
$pattern = '%d{d.m.Y H.i.s:u} [%p] %t: %m (at %M)%n';
//$pattern = '%d{d.m.Y H.i.s:u} [%p] %m %n';
$appenderlayout->setConversionPattern($pattern);
$appender->setLayout($appenderlayout);
$appender->activateOptions();
$log->removeAllAppenders();
$log->addAppender($appender);
$log->info(" *** Engine initializing ***");
function getLogger()
{
    global $log;
    return $log;
}
function initLogger()
{
    $loggerName = "log";
    // Iterate over all declared classes
    $classes = get_declared_classes();
    foreach ($classes as $class) {
        $reflection = new ReflectionClass($class);
        // If the class is internally defined by PHP or has no property called "logger", skip it.
开发者ID:vladikius,项目名称:tephlon,代码行数:31,代码来源:AELogger.php


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