LogEvent
An immutable structured log event.
Nothing is flattened early: the message template and property bag are preserved so structured sinks (JSON) can emit named fields, while text sinks call LogEvent::renderMessage() to interpolate.
Synopsis
Section titled “Synopsis”final readonly class LogEvent
| Source | Logging/LogEvent.php |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
$category | string | readonly. |
$exception | ?Throwable | readonly. |
$level | Level | readonly. |
$messageTemplate | string | readonly. |
$properties | array | readonly. |
$scope | array | readonly. |
$timestamp | float | readonly. |
Constructor
Section titled “Constructor”__construct()
Section titled “__construct()”public function __construct(float $timestamp, Level $level, string $category, string $messageTemplate, array<string, mixed> $properties = [], array<string, mixed> $scope = [], Throwable|null $exception = null): mixed
From $context[‘exception’] per PSR-3.
| Parameter | Type | Description |
|---|---|---|
$timestamp | float | UNIX timestamp with microseconds (microtime(true)). |
$level | Level | |
$category | string | |
$messageTemplate | string | Raw template, e.g. “Order {orderId} shipped”. |
$properties | array``<``string``, ``mixed``> | Named properties (PSR-3 $context sans “exception”). |
$scope | array``<``string``, ``mixed``> | Ambient scope properties merged in at emit time. |
$exception | Throwable` | “null` |
Returns mixed
Methods
Section titled “Methods”| Method | Description |
|---|---|
renderMessage(): string | Interpolate {placeholder} tokens in the template using properties then scope. |
renderMessage()
Section titled “renderMessage()”public function renderMessage(): string
Interpolate {placeholder} tokens in the template using properties then scope.
Non-scalar / non-stringable values are left as-is (placeholder kept). Mirrors PSR-3 interpolation semantics.
Returns string