TYPO3 CMS  TYPO3_6-2
LogLevel.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Log;
3 
21 class LogLevel {
22 
31  const EMERGENCY = 0;
39  const ALERT = 1;
47  const CRITICAL = 2;
55  const ERROR = 3;
64  const WARNING = 4;
72  const NOTICE = 5;
80  const INFO = 6;
88  const DEBUG = 7;
94  static protected $levels = array(
95  self::EMERGENCY => 'EMERGENCY',
96  self::ALERT => 'ALERT',
97  self::CRITICAL => 'CRITICAL',
98  self::ERROR => 'ERROR',
99  self::WARNING => 'WARNING',
100  self::NOTICE => 'NOTICE',
101  self::INFO => 'INFO',
102  self::DEBUG => 'DEBUG'
103  );
104 
111  static public function getName($level) {
112  self::validateLevel($level);
113  return self::$levels[$level];
114  }
115 
123  static public function isValidLevel($level) {
124  return \TYPO3\CMS\Core\Utility\MathUtility::isIntegerInRange($level, self::EMERGENCY, self::DEBUG);
125  }
126 
134  static public function validateLevel($level) {
135  if (!self::isValidLevel($level)) {
136  throw new \Psr\Log\InvalidArgumentException('Invalid Log Level.', 1321637121);
137  }
138  }
139 
146  static public function normalizeLevel($level) {
147  if (is_string($level) && defined(__CLASS__ . '::' . strtoupper($level))) {
148  $level = constant(__CLASS__ . '::' . strtoupper($level));
149  }
150 
151  return $level;
152  }
153 
154 }
static validateLevel($level)
Definition: LogLevel.php:134
static normalizeLevel($level)
Definition: LogLevel.php:146
static isValidLevel($level)
Definition: LogLevel.php:123
static getName($level)
Definition: LogLevel.php:111