Passed
Pull Request — master (#816)
by butschster
06:28
created

LogTracerFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 22
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A make() 0 7 1
A __construct() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Telemetry;
6
7
use Psr\Log\LoggerInterface;
8
use Ramsey\Uuid\UuidFactory;
9
use Spiral\Core\ScopeInterface;
10
use Spiral\Logger\LogsInterface;
11
12
/**
13
 * @internal The component is under development.
14
 * Something may be changed in the future. We will stable it soon.
15
 * Feedback is welcome {@link https://github.com/spiral/framework/discussions/822}.
16
 */
17
final class LogTracerFactory implements TracerFactoryInterface
18
{
19
    public const LOG_CHANNEL = 'telemetry';
20
21
    private readonly LoggerInterface $logger;
22
23 1
    public function __construct(
24
        private readonly ScopeInterface $scope,
25
        private readonly ClockInterface $clock,
26
        LogsInterface $logs,
27
        string $channel = self::LOG_CHANNEL
28
    ) {
29 1
        $this->logger = $logs->getLogger($channel);
0 ignored issues
show
Bug introduced by
The property logger is declared read-only in Spiral\Telemetry\LogTracerFactory.
Loading history...
30
    }
31
32 1
    public function make(array $context = []): TracerInterface
33
    {
34 1
        return new LogTracer(
35 1
            $this->scope,
36 1
            $this->clock,
37 1
            $this->logger,
38 1
            new UuidFactory()
39
        );
40
    }
41
}
42