Passed
Pull Request — master (#65)
by Sergey
03:06
created

LogDependencyProvider::addProcessors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file is part of the Spryker Commerce OS.
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace Pyz\Yves\Log;
9
10
use Spryker\Yves\Kernel\Container;
11
use Spryker\Yves\Log\LogDependencyProvider as SprykerLogDependencyProvider;
12
use Spryker\Yves\Log\Plugin\Handler\ExceptionStreamHandlerPlugin;
13
use Spryker\Yves\Log\Plugin\Handler\StreamHandlerPlugin;
14
use Spryker\Yves\Log\Plugin\Processor\EnvironmentProcessorPlugin;
15
use Spryker\Yves\Log\Plugin\Processor\GuzzleBodyProcessorPlugin;
16
use Spryker\Yves\Log\Plugin\Processor\PsrLogMessageProcessorPlugin;
17
use Spryker\Yves\Log\Plugin\Processor\RequestProcessorPlugin;
18
use Spryker\Yves\Log\Plugin\Processor\ResponseProcessorPlugin;
19
use Spryker\Yves\Log\Plugin\Processor\ServerProcessorPlugin;
20
21
class LogDependencyProvider extends SprykerLogDependencyProvider
22
{
23
    /**
24
     * @param \Spryker\Yves\Kernel\Container $container
25
     *
26
     * @return \Spryker\Yves\Kernel\Container
27
     */
28
    protected function addLogHandlers(Container $container): Container
29
    {
30
        $container->set(static::LOG_HANDLERS, function () {
31
            return $this->getLogHandlers();
32
        });
33
34
        return $container;
35
    }
36
37
    /**
38
     * @return array<\Monolog\Handler\HandlerInterface>
39
     */
40
    protected function getLogHandlers(): array
41
    {
42
        return [
43
            new StreamHandlerPlugin(),
44
            new ExceptionStreamHandlerPlugin(),
45
        ];
46
    }
47
48
    /**
49
     * @param \Spryker\Yves\Kernel\Container $container
50
     *
51
     * @return \Spryker\Yves\Kernel\Container
52
     */
53
    protected function addProcessors(Container $container): Container
54
    {
55
        $container->set(static::LOG_PROCESSORS, function () {
56
            return $this->getProcessors();
57
        });
58
59
        return $container;
60
    }
61
62
    /**
63
     * @return array<\Spryker\Shared\Log\Dependency\Plugin\LogProcessorPluginInterface>
64
     */
65
    protected function getProcessors(): array
66
    {
67
        return [
68
            new PsrLogMessageProcessorPlugin(),
69
            new EnvironmentProcessorPlugin(),
70
            new ServerProcessorPlugin(),
71
            new RequestProcessorPlugin(),
72
            new ResponseProcessorPlugin(),
73
            new GuzzleBodyProcessorPlugin(),
74
        ];
75
    }
76
}
77