StreamHandler::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 14
rs 9.9666
1
<?php
2
3
/*
4
 *  This file is part of the Micro framework package.
5
 *
6
 *  (c) Stanislau Komar <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 */
11
12
namespace Micro\Plugin\Logger\Monolog\Business\Handler\Type\Stream;
13
14
use Micro\Plugin\Logger\Monolog\Business\Handler\Type\AbstractHandler;
15
use Micro\Plugin\Logger\Monolog\Configuration\Handler\Type\HandlerStreamConfigurationInterface;
16
use Monolog\Handler\StreamHandler as MonologStreamHandler;
17
use Monolog\LogRecord;
18
19
/**
20
 * @author Stanislau Komar <[email protected]>
21
 *
22
 * @codeCoverageIgnore
23
 */
24
class StreamHandler extends AbstractHandler
25
{
26
    /** @psalm-suppress PropertyNotSetInConstructor */
27
    private MonologStreamHandler $handler;
28
29
    public function configure(): void
30
    {
31
        /** @var HandlerStreamConfigurationInterface $configuration */
32
        $configuration = $this->handlerConfiguration;
33
34
        $this->handler = new MonologStreamHandler(
35
            $configuration->getLogFile(),
36
            // @phpstan-ignore-next-line
37
            $this->loggerProviderTypeConfiguration
38
                ->getLogLevel()
39
                ->level(),
40
            true,
41
            null,
42
            $configuration->useLocking(),
43
        );
44
    }
45
46
    protected function write(LogRecord $record): void
47
    {
48
        $this->handler->write($record);
49
    }
50
}
51