Files
client-php/src/LogEvent.php

44 lines
1.2 KiB
PHP
Raw Normal View History

2025-09-06 01:21:02 +02:00
<?php
namespace LogDb\Client;
2025-09-06 01:38:42 +02:00
use DateTimeInterface;
2025-09-06 01:35:04 +02:00
use JsonSerializable;
class LogEvent implements JsonSerializable
2025-09-06 01:21:02 +02:00
{
public function __construct(
public readonly string $brief,
public readonly ?string $detail = null,
public readonly ?string $level = null,
public readonly ?string $scope = null,
public readonly ?string $source = null,
public readonly ?string $origin = null,
public readonly array $context = [],
2025-09-06 01:38:42 +02:00
public readonly ?DateTimeInterface $date = null,
2025-09-06 01:21:02 +02:00
)
{
}
2025-09-06 01:35:04 +02:00
public function jsonSerialize(): mixed
{
$context = $this->context;
$scope = $this->scope;
if (isset($context['_scope'])) {
$scope = $context['_scope'];
unset($context['_scope']);
}
2025-09-06 01:35:04 +02:00
return [
'brief' => $this->brief,
'detail' => $this->detail,
'level' => $this->level,
'scope' => $scope,
2025-09-06 01:35:04 +02:00
'source' => $this->source,
'origin' => $this->origin,
'context' => $context,
2025-09-06 01:35:04 +02:00
'date' => $this->date?->format('Y-m-d H:i:s P'),
];
}
2025-09-06 01:21:02 +02:00
}