1 | <?php |
||
24 | class Logger extends AbstractLogger implements LoggerInterface |
||
25 | { |
||
26 | /** |
||
27 | * @var string|null |
||
28 | */ |
||
29 | protected $facility; |
||
30 | |||
31 | /** |
||
32 | * @var PublisherInterface |
||
33 | */ |
||
34 | protected $publisher; |
||
35 | |||
36 | /** |
||
37 | * Creates a PSR-3 Logger for GELF/Graylog2 |
||
38 | * |
||
39 | * @param PublisherInterface|null $publisher |
||
40 | * @param string|null $facility |
||
41 | */ |
||
42 | 16 | public function __construct( |
|
52 | |||
53 | /** |
||
54 | * Publishes a given message and context with given level |
||
55 | * |
||
56 | * @param mixed $level |
||
57 | * @param mixed $rawMessage |
||
58 | * @param array $context |
||
59 | */ |
||
60 | 14 | public function log($level, $rawMessage, array $context = array()) |
|
73 | |||
74 | /** |
||
75 | * Returns the currently used publisher |
||
76 | * |
||
77 | * @return PublisherInterface |
||
78 | */ |
||
79 | 1 | public function getPublisher() |
|
83 | |||
84 | /** |
||
85 | * Sets a new publisher |
||
86 | * |
||
87 | * @param PublisherInterface $publisher |
||
88 | */ |
||
89 | 1 | public function setPublisher(PublisherInterface $publisher) |
|
93 | |||
94 | /** |
||
95 | * Returns the faciilty-name used in GELF |
||
96 | * |
||
97 | * @return string|null |
||
98 | */ |
||
99 | 1 | public function getFacility() |
|
103 | |||
104 | /** |
||
105 | * Sets the facility for GELF messages |
||
106 | * |
||
107 | * @param string|null $facility |
||
108 | */ |
||
109 | 16 | public function setFacility($facility = null) |
|
113 | |||
114 | /** |
||
115 | * @return Message |
||
116 | */ |
||
117 | 14 | protected function createMessage() |
|
121 | |||
122 | /** |
||
123 | * Initializes message-object |
||
124 | * |
||
125 | * @param mixed $level |
||
126 | * @param mixed $message |
||
127 | * @param array $context |
||
128 | * @return Message |
||
129 | */ |
||
130 | 14 | protected function initMessage($level, $message, array $context) |
|
149 | |||
150 | /** |
||
151 | * Initializes context array, ensuring all values are string-safe |
||
152 | * |
||
153 | * @param array $context |
||
154 | * @return array |
||
155 | */ |
||
156 | 14 | protected function initContext($context) |
|
187 | |||
188 | /** |
||
189 | * Initializes Exceptiondata with given message |
||
190 | * |
||
191 | * @param Message $message |
||
192 | * @param Exception $exception |
||
193 | */ |
||
194 | 1 | protected function initExceptionData(Message $message, Exception $exception) |
|
215 | |||
216 | /** |
||
217 | * Interpolates context values into the message placeholders. |
||
218 | * |
||
219 | * Reference implementation |
||
220 | * @link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#12-message |
||
221 | * |
||
222 | * @param mixed $message |
||
223 | * @param array $context |
||
224 | * @return string |
||
225 | */ |
||
226 | 14 | private static function interpolate($message, array $context) |
|
237 | } |
||
238 |