TYPO3 CMS  TYPO3_7-6
LogLevel.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Log;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 class LogLevel
21 {
30  const EMERGENCY = 0;
31 
39  const ALERT = 1;
40 
48  const CRITICAL = 2;
49 
57  const ERROR = 3;
58 
67  const WARNING = 4;
68 
76  const NOTICE = 5;
77 
85  const INFO = 6;
86 
94  const DEBUG = 7;
95 
101  protected static $levels = [
102  self::EMERGENCY => 'EMERGENCY',
103  self::ALERT => 'ALERT',
104  self::CRITICAL => 'CRITICAL',
105  self::ERROR => 'ERROR',
106  self::WARNING => 'WARNING',
107  self::NOTICE => 'NOTICE',
108  self::INFO => 'INFO',
109  self::DEBUG => 'DEBUG'
110  ];
111 
118  public static function getName($level)
119  {
120  self::validateLevel($level);
121  return self::$levels[$level];
122  }
123 
131  public static function isValidLevel($level)
132  {
133  return \TYPO3\CMS\Core\Utility\MathUtility::isIntegerInRange($level, self::EMERGENCY, self::DEBUG);
134  }
135 
143  public static function validateLevel($level)
144  {
145  if (!self::isValidLevel($level)) {
146  throw new \Psr\Log\InvalidArgumentException('Invalid Log Level.', 1321637121);
147  }
148  }
149 
156  public static function normalizeLevel($level)
157  {
158  if (is_string($level) && defined(__CLASS__ . '::' . strtoupper($level))) {
159  $level = constant(__CLASS__ . '::' . strtoupper($level));
160  }
161 
162  return $level;
163  }
164 }
static validateLevel($level)
Definition: LogLevel.php:143
static normalizeLevel($level)
Definition: LogLevel.php:156
static isValidLevel($level)
Definition: LogLevel.php:131
static getName($level)
Definition: LogLevel.php:118