LogEntry
Read onlyYes
FinalYes
Complete log entry ready for processing.
LogEntry wraps the user-provided LogRecord together with contextual information resolved at emit time:
- InstrumentationScope from the Logger
- SpanContext from the context storage (for trace correlation)
- Resolved timestamp
This is the internal type passed to LogProcessor and LogExporter implementations.
Properties
- $record : LogRecord
- $resource : Resource
- $scope : InstrumentationScope
- $spanContext : SpanContext|null
- $timestamp : DateTimeImmutable
Methods
- __construct() : mixed
- fromArray() : self
- Create a LogEntry from a normalized array representation.
-
normalize()
: array{record: array{severity: int, body: string, attributes: array
, timestamp: null|string, observedTimestamp: null|string}, resource: array{attributes: array }, scope: array{name: string, version: string, schemaUrl: null|string, attributes: array }, timestamp: string, spanContext: null|array{traceId: array{hex: string}, spanId: array{hex: string}, parentSpanId: null|array{hex: string}, isRemote: bool, traceFlags: array{byte: int}, traceState: array{entries: array }}} - Normalize the LogEntry to an array representation for serialization.
Properties
$record
public
LogRecord
$record
$resource
public
Resource
$resource
$scope
public
InstrumentationScope
$scope
$spanContext
public
SpanContext|null
$spanContext
= null
$timestamp
public
DateTimeImmutable
$timestamp
Methods
__construct()
public
__construct(LogRecord $record, Resource $resource, InstrumentationScope $scope, DateTimeImmutable $timestamp[, SpanContext|null $spanContext = null ]) : mixed
Parameters
- $record : LogRecord
- $resource : Resource
- $scope : InstrumentationScope
- $timestamp : DateTimeImmutable
- $spanContext : SpanContext|null = null
fromArray()
Create a LogEntry from a normalized array representation.
public
static fromArray(array{record: array{severity: int, body: string, attributes: array, timestamp: null|string, observedTimestamp: null|string}, resource: array{attributes: array}, scope: array{name: string, version: string, schemaUrl: null|string, attributes: array}, timestamp: string, spanContext: null|array{traceId: array{hex: string}, spanId: array{hex: string}, parentSpanId: null|array{hex: string}, isRemote: bool, traceFlags: array{byte: int}, traceState: array{entries: array}}} $data) : self
Parameters
-
$data
: array{record: array{severity: int, body: string, attributes: array
, timestamp: null|string, observedTimestamp: null|string}, resource: array{attributes: array }, scope: array{name: string, version: string, schemaUrl: null|string, attributes: array }, timestamp: string, spanContext: null|array{traceId: array{hex: string}, spanId: array{hex: string}, parentSpanId: null|array{hex: string}, isRemote: bool, traceFlags: array{byte: int}, traceState: array{entries: array }}} -
Normalized LogEntry data
Return values
selfnormalize()
Normalize the LogEntry to an array representation for serialization.
public
normalize() : array{record: array{severity: int, body: string, attributes: array, timestamp: null|string, observedTimestamp: null|string}, resource: array{attributes: array}, scope: array{name: string, version: string, schemaUrl: null|string, attributes: array}, timestamp: string, spanContext: null|array{traceId: array{hex: string}, spanId: array{hex: string}, parentSpanId: null|array{hex: string}, isRemote: bool, traceFlags: array{byte: int}, traceState: array{entries: array}}}