Pull merge.
[yaffs-website] / web / core / lib / Drupal / Core / Logger / RfcLoggerTrait.php
1 <?php
2
3 namespace Drupal\Core\Logger;
4
5 /**
6  * A copy of \Psr\Log\LoggerTrait that uses RFC 5424 compliant log levels.
7  *
8  * Internal Drupal logger implementations should use this trait instead of
9  * \Psr\Log\LoggerTrait. Callers of those implementations are responsible for
10  * translating any other log level format to RFC 5424 compliant integers.
11  *
12  * @see https://groups.google.com/forum/#!topic/php-fig/Rc5YDhNdGz4
13  * @see https://www.drupal.org/node/2267545
14  */
15 trait RfcLoggerTrait {
16
17   /**
18    * {@inheritdoc}
19    */
20   public function emergency($message, array $context = []) {
21     $this->log(RfcLogLevel::EMERGENCY, $message, $context);
22   }
23
24   /**
25    * {@inheritdoc}
26    */
27   public function alert($message, array $context = []) {
28     $this->log(RfcLogLevel::ALERT, $message, $context);
29   }
30
31   /**
32    * {@inheritdoc}
33    */
34   public function critical($message, array $context = []) {
35     $this->log(RfcLogLevel::CRITICAL, $message, $context);
36   }
37
38   /**
39    * {@inheritdoc}
40    */
41   public function error($message, array $context = []) {
42     $this->log(RfcLogLevel::ERROR, $message, $context);
43   }
44
45   /**
46    * {@inheritdoc}
47    */
48   public function warning($message, array $context = []) {
49     $this->log(RfcLogLevel::WARNING, $message, $context);
50   }
51
52   /**
53    * {@inheritdoc}
54    */
55   public function notice($message, array $context = []) {
56     $this->log(RfcLogLevel::NOTICE, $message, $context);
57   }
58
59   /**
60    * {@inheritdoc}
61    */
62   public function info($message, array $context = []) {
63     $this->log(RfcLogLevel::INFO, $message, $context);
64   }
65
66   /**
67    * {@inheritdoc}
68    */
69   public function debug($message, array $context = []) {
70     $this->log(RfcLogLevel::DEBUG, $message, $context);
71   }
72
73   /**
74    * {@inheritdoc}
75    */
76   abstract public function log($level, $message, array $context = []);
77
78 }