‪TYPO3CMS  9.5
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 
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 
142  public static function ‪validateLevel($level)
143  {
144  if (!self::isValidLevel($level)) {
145  throw new \Psr\Log\InvalidArgumentException('Invalid Log Level.', 1321637121);
146  }
147  }
148 
155  public static function ‪normalizeLevel($level)
156  {
157  if (is_string($level) && defined(__CLASS__ . '::' . strtoupper($level))) {
158  $level = constant(__CLASS__ . '::' . strtoupper($level));
159  }
160 
161  return $level;
162  }
163 }
‪TYPO3\CMS\Core\Log\LogLevel\CRITICAL
‪const CRITICAL
Definition: LogLevel.php:48
‪TYPO3\CMS\Core\Log\LogLevel\INFO
‪const INFO
Definition: LogLevel.php:85
‪TYPO3\CMS\Core\Log
‪TYPO3\CMS\Core\Log\LogLevel\normalizeLevel
‪static int string normalizeLevel($level)
Definition: LogLevel.php:154
‪TYPO3\CMS\Core\Log\LogLevel\ALERT
‪const ALERT
Definition: LogLevel.php:39
‪TYPO3\CMS\Core\Log\LogLevel\ERROR
‪const ERROR
Definition: LogLevel.php:57
‪TYPO3\CMS\Core\Log\LogLevel\EMERGENCY
‪const EMERGENCY
Definition: LogLevel.php:30
‪TYPO3\CMS\Core\Log\LogLevel\isValidLevel
‪static bool isValidLevel($level)
Definition: LogLevel.php:130
‪TYPO3\CMS\Core\Log\LogLevel\WARNING
‪const WARNING
Definition: LogLevel.php:67
‪TYPO3\CMS\Core\Log\LogLevel\$levels
‪static array $levels
Definition: LogLevel.php:100
‪TYPO3\CMS\Core\Log\LogLevel\getName
‪static string getName($level)
Definition: LogLevel.php:117
‪TYPO3\CMS\Core\Log\LogLevel\validateLevel
‪static validateLevel($level)
Definition: LogLevel.php:141
‪TYPO3\CMS\Core\Log\LogLevel\NOTICE
‪const NOTICE
Definition: LogLevel.php:76
‪TYPO3\CMS\Core\Log\LogLevel\DEBUG
‪const DEBUG
Definition: LogLevel.php:94
‪TYPO3\CMS\Core\Log\LogLevel
Definition: LogLevel.php:21