Version 1
[yaffs-website] / web / core / lib / Drupal / Core / Logger / RfcLogLevel.php
1 <?php
2
3 namespace Drupal\Core\Logger;
4
5 use Drupal\Core\StringTranslation\TranslatableMarkup;
6
7 /**
8  * @defgroup logging_severity_levels Logging severity levels
9  * @{
10  * Logging severity levels as defined in RFC 5424.
11  *
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."
18  *
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 self::getLevels()
24  *
25  * @} End of "defgroup logging_severity_levels".
26  */
27
28 /**
29  * Defines various logging severity levels.
30  *
31  * @ingroup logging_severity_levels
32  */
33 class RfcLogLevel {
34
35   /**
36    * Log message severity -- Emergency: system is unusable.
37    */
38   const EMERGENCY = 0;
39
40   /**
41    * Log message severity -- Alert: action must be taken immediately.
42    */
43   const ALERT = 1;
44
45   /**
46    * Log message severity -- Critical conditions.
47    */
48   const CRITICAL = 2;
49
50   /**
51    * Log message severity -- Error conditions.
52    */
53   const ERROR = 3;
54
55   /**
56    * Log message severity -- Warning conditions.
57    */
58   const WARNING = 4;
59
60   /**
61    * Log message severity -- Normal but significant conditions.
62    */
63   const NOTICE = 5;
64
65   /**
66    * Log message severity -- Informational messages.
67    */
68   const INFO = 6;
69
70   /**
71    * Log message severity -- Debug-level messages.
72    */
73   const DEBUG = 7;
74
75   /**
76    * An array with the severity levels as keys and labels as values.
77    *
78    * @var array
79    */
80   protected static $levels;
81
82   /**
83    * Returns a list of severity levels, as defined in RFC 5424.
84    *
85    * @return array
86    *   Array of the possible severity levels for log messages.
87    *
88    * @see http://tools.ietf.org/html/rfc5424
89    * @ingroup logging_severity_levels
90    */
91   public static function getLevels() {
92     if (!static::$levels) {
93       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'),
102       ];
103     }
104
105     return static::$levels;
106   }
107
108 }