annotate core/lib/Drupal/Core/Logger/RfcLogLevel.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\Core\Logger;
Chris@0 4
Chris@0 5 use Drupal\Core\StringTranslation\TranslatableMarkup;
Chris@0 6
Chris@0 7 /**
Chris@0 8 * @defgroup logging_severity_levels Logging severity levels
Chris@0 9 * @{
Chris@0 10 * Logging severity levels as defined in RFC 5424.
Chris@0 11 *
Chris@0 12 * The constant definitions of this class correspond to the logging severity
Chris@0 13 * levels defined in RFC 5424, section 4.1.1. PHP supplies predefined LOG_*
Chris@0 14 * constants for use in the syslog() function, but their values on Windows
Chris@0 15 * builds do not correspond to RFC 5424. The associated PHP bug report was
Chris@0 16 * closed with the comment, "And it's also not a bug, as Windows just have less
Chris@0 17 * log levels," and "So the behavior you're seeing is perfectly normal."
Chris@0 18 *
Chris@0 19 * @see http://tools.ietf.org/html/rfc5424
Chris@0 20 * @see http://bugs.php.net/bug.php?id=18090
Chris@0 21 * @see http://php.net/manual/function.syslog.php
Chris@0 22 * @see http://php.net/manual/network.constants.php
Chris@17 23 * @see \Drupal\Core\Logger\RfcLogLevel::getLevels()
Chris@0 24 *
Chris@17 25 * @}
Chris@0 26 */
Chris@0 27
Chris@0 28 /**
Chris@0 29 * Defines various logging severity levels.
Chris@0 30 *
Chris@0 31 * @ingroup logging_severity_levels
Chris@0 32 */
Chris@0 33 class RfcLogLevel {
Chris@0 34
Chris@0 35 /**
Chris@0 36 * Log message severity -- Emergency: system is unusable.
Chris@0 37 */
Chris@0 38 const EMERGENCY = 0;
Chris@0 39
Chris@0 40 /**
Chris@0 41 * Log message severity -- Alert: action must be taken immediately.
Chris@0 42 */
Chris@0 43 const ALERT = 1;
Chris@0 44
Chris@0 45 /**
Chris@0 46 * Log message severity -- Critical conditions.
Chris@0 47 */
Chris@0 48 const CRITICAL = 2;
Chris@0 49
Chris@0 50 /**
Chris@0 51 * Log message severity -- Error conditions.
Chris@0 52 */
Chris@0 53 const ERROR = 3;
Chris@0 54
Chris@0 55 /**
Chris@0 56 * Log message severity -- Warning conditions.
Chris@0 57 */
Chris@0 58 const WARNING = 4;
Chris@0 59
Chris@0 60 /**
Chris@0 61 * Log message severity -- Normal but significant conditions.
Chris@0 62 */
Chris@0 63 const NOTICE = 5;
Chris@0 64
Chris@0 65 /**
Chris@0 66 * Log message severity -- Informational messages.
Chris@0 67 */
Chris@0 68 const INFO = 6;
Chris@0 69
Chris@0 70 /**
Chris@0 71 * Log message severity -- Debug-level messages.
Chris@0 72 */
Chris@0 73 const DEBUG = 7;
Chris@0 74
Chris@0 75 /**
Chris@0 76 * An array with the severity levels as keys and labels as values.
Chris@0 77 *
Chris@0 78 * @var array
Chris@0 79 */
Chris@0 80 protected static $levels;
Chris@0 81
Chris@0 82 /**
Chris@0 83 * Returns a list of severity levels, as defined in RFC 5424.
Chris@0 84 *
Chris@0 85 * @return array
Chris@0 86 * Array of the possible severity levels for log messages.
Chris@0 87 *
Chris@0 88 * @see http://tools.ietf.org/html/rfc5424
Chris@0 89 * @ingroup logging_severity_levels
Chris@0 90 */
Chris@0 91 public static function getLevels() {
Chris@0 92 if (!static::$levels) {
Chris@0 93 static::$levels = [
Chris@0 94 static::EMERGENCY => new TranslatableMarkup('Emergency'),
Chris@0 95 static::ALERT => new TranslatableMarkup('Alert'),
Chris@0 96 static::CRITICAL => new TranslatableMarkup('Critical'),
Chris@0 97 static::ERROR => new TranslatableMarkup('Error'),
Chris@0 98 static::WARNING => new TranslatableMarkup('Warning'),
Chris@0 99 static::NOTICE => new TranslatableMarkup('Notice'),
Chris@0 100 static::INFO => new TranslatableMarkup('Info'),
Chris@0 101 static::DEBUG => new TranslatableMarkup('Debug'),
Chris@0 102 ];
Chris@0 103 }
Chris@0 104
Chris@0 105 return static::$levels;
Chris@0 106 }
Chris@0 107
Chris@0 108 }