1 | <?php |
||
24 | class Logger extends AbstractLogger implements LoggerInterface |
||
25 | { |
||
26 | /** |
||
27 | * @var string|null |
||
28 | */ |
||
29 | protected $facility; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $defaultContext; |
||
35 | |||
36 | /** |
||
37 | * @var PublisherInterface |
||
38 | */ |
||
39 | protected $publisher; |
||
40 | |||
41 | /** |
||
42 | * Creates a PSR-3 Logger for GELF/Graylog2 |
||
43 | * |
||
44 | * @param PublisherInterface|null $publisher |
||
45 | * @param string|null $facility |
||
46 | * @param array $defaultContext |
||
47 | */ |
||
48 | 16 | public function __construct( |
|
60 | |||
61 | /** |
||
62 | * Publishes a given message and context with given level |
||
63 | * |
||
64 | * @param mixed $level |
||
65 | * @param mixed $rawMessage |
||
66 | * @param array $context |
||
67 | */ |
||
68 | 14 | public function log($level, $rawMessage, array $context = array()) |
|
81 | |||
82 | /** |
||
83 | * Returns the currently used publisher |
||
84 | * |
||
85 | * @return PublisherInterface |
||
86 | */ |
||
87 | 1 | public function getPublisher() |
|
91 | |||
92 | /** |
||
93 | * Sets a new publisher |
||
94 | * |
||
95 | * @param PublisherInterface $publisher |
||
96 | */ |
||
97 | 1 | public function setPublisher(PublisherInterface $publisher) |
|
101 | |||
102 | /** |
||
103 | * Returns the faciilty-name used in GELF |
||
104 | * |
||
105 | * @return string|null |
||
106 | */ |
||
107 | 1 | public function getFacility() |
|
111 | |||
112 | /** |
||
113 | * Sets the facility for GELF messages |
||
114 | * |
||
115 | * @param string|null $facility |
||
116 | */ |
||
117 | 16 | public function setFacility($facility = null) |
|
121 | |||
122 | /** |
||
123 | * @return array |
||
124 | */ |
||
125 | 14 | public function getDefaultContext() |
|
129 | |||
130 | /** |
||
131 | * @param array $defaultContext |
||
132 | */ |
||
133 | 16 | public function setDefaultContext($defaultContext) |
|
137 | |||
138 | /** |
||
139 | * Initializes message-object |
||
140 | * |
||
141 | * @param mixed $level |
||
142 | * @param mixed $message |
||
143 | * @param array $context |
||
144 | * @return Message |
||
145 | */ |
||
146 | 14 | protected function initMessage($level, $message, array $context) |
|
168 | |||
169 | /** |
||
170 | * Initializes context array, ensuring all values are string-safe |
||
171 | * |
||
172 | * @param array $context |
||
173 | * @return array |
||
174 | */ |
||
175 | 14 | protected function initContext($context) |
|
206 | |||
207 | /** |
||
208 | * Initializes Exceptiondata with given message |
||
209 | * |
||
210 | * @param Message $message |
||
211 | * @param Exception $exception |
||
212 | */ |
||
213 | 1 | protected function initExceptionData(Message $message, Exception $exception) |
|
234 | |||
235 | /** |
||
236 | * Interpolates context values into the message placeholders. |
||
237 | * |
||
238 | * Reference implementation |
||
239 | * @link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#12-message |
||
240 | * |
||
241 | * @param mixed $message |
||
242 | * @param array $context |
||
243 | * @return string |
||
244 | */ |
||
245 | 14 | private static function interpolate($message, array $context) |
|
256 | } |
||
257 |