blob: 0b8db152d1efde058edb94a8f44c2840013c670b (
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
|
<?php
declare(strict_types=1);
namespace OpenTelemetry\SDK\Logs;
use OpenTelemetry\API\Logs\LoggerInterface;
use OpenTelemetry\API\Logs\LogRecord;
use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface;
/**
* Note that this logger class is deliberately NOT psr-3 compatible, per spec: "Note: this document defines a log
* backend API. The API is not intended to be called by application developers directly."
*
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/bridge-api.md
*/
class Logger implements LoggerInterface
{
private InstrumentationScopeInterface $scope;
private LoggerSharedState $loggerSharedState;
public function __construct(LoggerSharedState $loggerSharedState, InstrumentationScopeInterface $scope)
{
$this->loggerSharedState = $loggerSharedState;
$this->scope = $scope;
}
public function emit(LogRecord $logRecord): void
{
$readWriteLogRecord = new ReadWriteLogRecord($this->scope, $this->loggerSharedState, $logRecord);
// @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md#onemit
$this->loggerSharedState->getProcessor()->onEmit(
$readWriteLogRecord,
$readWriteLogRecord->getContext(),
);
}
}
|