summaryrefslogtreecommitdiff
path: root/vendor/open-telemetry/sdk/Logs/LoggerSharedState.php
blob: aeeb455185d26c7efa285e1ec2b4b5f6563cf0fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php

declare(strict_types=1);

namespace OpenTelemetry\SDK\Logs;

use OpenTelemetry\SDK\Common\Future\CancellationInterface;
use OpenTelemetry\SDK\Resource\ResourceInfo;

class LoggerSharedState
{
    private ResourceInfo $resource;
    private LogRecordProcessorInterface $processor;
    private LogRecordLimits $limits;
    private ?bool $shutdownResult = null;

    public function __construct(
        ResourceInfo $resource,
        LogRecordLimits $limits,
        LogRecordProcessorInterface $processor
    ) {
        $this->resource = $resource;
        $this->limits = $limits;
        $this->processor = $processor;
    }
    public function hasShutdown(): bool
    {
        return null !== $this->shutdownResult;
    }

    public function getResource(): ResourceInfo
    {
        return $this->resource;
    }

    public function getProcessor(): LogRecordProcessorInterface
    {
        return $this->processor;
    }

    public function getLogRecordLimits(): LogRecordLimits
    {
        return $this->limits;
    }

    public function shutdown(?CancellationInterface $cancellation = null): bool
    {
        if ($this->shutdownResult !== null) {
            return $this->shutdownResult;
        }
        $this->shutdownResult = $this->processor->shutdown($cancellation);

        return $this->shutdownResult;
    }

    public function forceFlush(?CancellationInterface $cancellation = null): bool
    {
        return $this->processor->forceFlush($cancellation);
    }
}