1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Arp\LaminasMonolog\Factory\Formatter; |
6
|
|
|
|
7
|
|
|
use Laminas\ServiceManager\Exception\ServiceNotCreatedException; |
8
|
|
|
use Monolog\Formatter\LineFormatter; |
9
|
|
|
use Psr\Container\ContainerExceptionInterface; |
10
|
|
|
use Psr\Container\ContainerInterface; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Create a new LineFormatter instance based on configuration options |
14
|
|
|
* |
15
|
|
|
* @author Alex Patterson <[email protected]> |
16
|
|
|
* @package Arp\LaminasMonolog\Factory\Formatter |
17
|
|
|
*/ |
18
|
|
|
final class LineFormatterFactory extends AbstractNormalizerFormatterFactory |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @param ContainerInterface $container |
22
|
|
|
* @param string $requestedName |
23
|
|
|
* @param array<mixed>|null $options |
24
|
|
|
* |
25
|
|
|
* @return LineFormatter |
26
|
|
|
* |
27
|
|
|
* @throws ServiceNotCreatedException |
28
|
|
|
* @throws ContainerExceptionInterface |
29
|
|
|
*/ |
30
|
4 |
|
public function __invoke(ContainerInterface $container, string $requestedName, array $options = null): LineFormatter |
31
|
|
|
{ |
32
|
4 |
|
$options = $options ?? $this->getServiceOptions($container, $requestedName); |
33
|
|
|
|
34
|
4 |
|
$formatter = new LineFormatter( |
35
|
4 |
|
$options['format'] ?? null, |
36
|
4 |
|
$options['date_format'] ?? null, |
37
|
4 |
|
isset($options['allow_inline_line_breaks']) && $options['allow_inline_line_breaks'], |
38
|
4 |
|
isset($options['ignore_empty_context_and_extra']) && $options['ignore_empty_context_and_extra'], |
39
|
4 |
|
isset($options['include_stack_traces']) && $options['include_stack_traces'] |
40
|
|
|
); |
41
|
|
|
|
42
|
4 |
|
$this->configureNormalizerFormatter($formatter, $options); |
43
|
|
|
|
44
|
4 |
|
return $formatter; |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|