1 | <?php |
||
9 | class StandardFormatter implements FormatterInterface |
||
10 | { |
||
11 | /** |
||
12 | * The string to return is composed by some placeholders |
||
13 | * {date} timestamp of the log |
||
14 | * {name} logger name |
||
15 | * {level} log level |
||
16 | * {message} message to log (can contains placeholder too) |
||
17 | * {context} un-replaced variables |
||
18 | * {exception} exception trace |
||
19 | * |
||
20 | * @var string $format |
||
21 | */ |
||
22 | private $format = '[{date}] {name}.{level}: {message} [{context}] [{exception}]'; |
||
23 | |||
24 | /** |
||
25 | * @var string dateFormat |
||
26 | */ |
||
27 | private $dateFormat; |
||
28 | |||
29 | /** |
||
30 | * StandardFormatter constructor. |
||
31 | * |
||
32 | * @param string $dateFormat |
||
33 | */ |
||
34 | 2 | public function __construct($dateFormat = 'Y-m-d H:i:s') |
|
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | 4 | public function interpolate(string $name, string $level, string $message, array $context = []): string |
|
89 | |||
90 | /** |
||
91 | * Return a timestamp for logger |
||
92 | * (Is a specific method for a better testability) |
||
93 | * |
||
94 | * @return string |
||
95 | */ |
||
96 | 1 | protected function getTimestampFromImmutable(): string |
|
102 | } |