2 namespace TYPO3\CMS\Core\Log
;
4 /***************************************************************
7 * (c) 2011-2012 Ingo Renner (ingo@typo3.org)
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
27 * Log levels according to RFC 3164
29 * @author Ingo Renner <ingo@typo3.org>
36 * Emergency: system is unusable
38 * You'd likely not be able to reach the system. You better have an SLA in
39 * place when this happens.
45 * Alert: action must be taken immediately
47 * Example: Entire website down, database unavailable, etc.
53 * Critical: critical conditions
55 * Example: unexpected exception.
61 * Error: error conditions
63 * Example: Runtime error.
69 * Warning: warning conditions
71 * Examples: Use of deprecated APIs, undesirable things that are not
78 * Notice: normal but significant condition
80 * Example: things you should have a look at, nothing to worry about though.
86 * Informational: informational messages
88 * Examples: User logs in, SQL logs.
94 * Debug: debug-level messages
96 * Example: Detailed status information.
102 * Reverse look up of log level to level name.
106 static protected $levels = array(
107 self
::EMERGENCY
=> 'EMERGENCY',
108 self
::ALERT
=> 'ALERT',
109 self
::CRITICAL
=> 'CRITICAL',
110 self
::ERROR
=> 'ERROR',
111 self
::WARNING
=> 'WARNING',
112 self
::NOTICE
=> 'NOTICE',
113 self
::INFO
=> 'INFO',
114 self
::DEBUG
=> 'DEBUG'
118 * Resolves the name of a log level.
120 * @param integer $level Log level.
121 * @return string Log level name.
123 static public function getName($level) {
124 self
::validateLevel($level);
125 return self
::$levels[$level];
129 * Checks a level for validity,
130 * whether it is an integer and in the range of 0-7.
132 * @param integer $level log level to validate
133 * @return boolean TRUE if the given log level is valid, FALSE otherwise
135 static public function isValidLevel($level) {
136 return \TYPO3\CMS\Core\Utility\MathUtility
::isIntegerInRange($level, self
::EMERGENCY
, self
::DEBUG
);
140 * Validates a log level.
142 * @param integer $level log level to validate
144 * @throws \RangeException if the given log level is invalid
146 static public function validateLevel($level) {
147 if (!self
::isValidLevel($level)) {
148 throw new \
RangeException('Invalid Log Level.', 1321637121);