3 namespace Drupal\Core\Logger;
5 use Drupal\Core\StringTranslation\TranslatableMarkup;
8 * @defgroup logging_severity_levels Logging severity levels
10 * Logging severity levels as defined in RFC 5424.
12 * The constant definitions of this class correspond to the logging severity
13 * levels defined in RFC 5424, section 4.1.1. PHP supplies predefined LOG_*
14 * constants for use in the syslog() function, but their values on Windows
15 * builds do not correspond to RFC 5424. The associated PHP bug report was
16 * closed with the comment, "And it's also not a bug, as Windows just have less
17 * log levels," and "So the behavior you're seeing is perfectly normal."
19 * @see http://tools.ietf.org/html/rfc5424
20 * @see http://bugs.php.net/bug.php?id=18090
21 * @see http://php.net/manual/function.syslog.php
22 * @see http://php.net/manual/network.constants.php
23 * @see \Drupal\Core\Logger\RfcLogLevel::getLevels()
29 * Defines various logging severity levels.
31 * @ingroup logging_severity_levels
36 * Log message severity -- Emergency: system is unusable.
41 * Log message severity -- Alert: action must be taken immediately.
46 * Log message severity -- Critical conditions.
51 * Log message severity -- Error conditions.
56 * Log message severity -- Warning conditions.
61 * Log message severity -- Normal but significant conditions.
66 * Log message severity -- Informational messages.
71 * Log message severity -- Debug-level messages.
76 * An array with the severity levels as keys and labels as values.
80 protected static $levels;
83 * Returns a list of severity levels, as defined in RFC 5424.
86 * Array of the possible severity levels for log messages.
88 * @see http://tools.ietf.org/html/rfc5424
89 * @ingroup logging_severity_levels
91 public static function getLevels() {
92 if (!static::$levels) {
94 static::EMERGENCY => new TranslatableMarkup('Emergency'),
95 static::ALERT => new TranslatableMarkup('Alert'),
96 static::CRITICAL => new TranslatableMarkup('Critical'),
97 static::ERROR => new TranslatableMarkup('Error'),
98 static::WARNING => new TranslatableMarkup('Warning'),
99 static::NOTICE => new TranslatableMarkup('Notice'),
100 static::INFO => new TranslatableMarkup('Info'),
101 static::DEBUG => new TranslatableMarkup('Debug'),
105 return static::$levels;