Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 70
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
LogServiceProvider
0.00% covered (danger)
0.00%
0 / 70
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 __invoke
0.00% covered (danger)
0.00%
0 / 70
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3/**
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; under version 2
7 * of the License (non-upgradable).
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 *
18 * Copyright (c) 2021 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
19 */
20
21declare(strict_types=1);
22
23namespace oat\oatbox\log\ServiceProvider;
24
25use oat\oatbox\log\LoggerService;
26use oat\oatbox\session\SessionService;
27use oat\oatbox\log\logger\AdvancedLogger;
28use oat\oatbox\log\logger\extender\UserContextExtender;
29use oat\oatbox\log\logger\extender\RequestContextExtender;
30use oat\oatbox\log\logger\extender\ExceptionContextExtender;
31use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
32use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
33
34use function Symfony\Component\DependencyInjection\Loader\Configurator\param;
35use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
36
37class LogServiceProvider implements ContainerServiceProviderInterface
38{
39    public function __invoke(ContainerConfigurator $configurator): void
40    {
41        $services = $configurator->services();
42
43        $services->set(ExceptionContextExtender::class, ExceptionContextExtender::class);
44        $services->set(RequestContextExtender::class, RequestContextExtender::class);
45        $services
46            ->set(UserContextExtender::class, UserContextExtender::class)
47            ->args(
48                [
49                    service(SessionService::SERVICE_ID),
50                ]
51            );
52
53        $services
54            ->set(UserContextExtender::ACL_SERVICE_ID, UserContextExtender::class)
55            ->args(
56                [
57                    service(SessionService::SERVICE_ID),
58                    true,
59                ]
60            );
61
62        $services
63            ->set(AdvancedLogger::class, AdvancedLogger::class)
64            ->public()
65            ->call(
66                'addContextExtender',
67                [
68                    service(ExceptionContextExtender::class),
69                ]
70            )
71            ->call(
72                'addContextExtender',
73                [
74                    service(RequestContextExtender::class),
75                ]
76            )
77            ->call(
78                'addContextExtender',
79                [
80                    service(UserContextExtender::class),
81                ]
82            )
83            ->args(
84                [
85                    service(LoggerService::SERVICE_ID),
86                ]
87            );
88
89        $services
90            ->set(AdvancedLogger::ACL_SERVICE_ID, AdvancedLogger::class)
91            ->public()
92            ->args(
93                [
94                    service(LoggerService::SERVICE_ID),
95                ]
96            )
97            ->call(
98                'addContextExtender',
99                [
100                    service(ExceptionContextExtender::class),
101                ]
102            )
103            ->call(
104                'addContextExtender',
105                [
106                    service(RequestContextExtender::class),
107                ]
108            )
109            ->call(
110                'addContextExtender',
111                [
112                    service(UserContextExtender::ACL_SERVICE_ID),
113                ]
114            );
115    }
116}