Add date, event batching

This commit is contained in:
2025-09-06 01:35:04 +02:00
parent 5010d085f5
commit f710aa0e6f
3 changed files with 42 additions and 7 deletions

View File

@@ -2,7 +2,9 @@
namespace LogDb\Client;
class LogEvent
use JsonSerializable;
class LogEvent implements JsonSerializable
{
public function __construct(
public readonly string $brief,
@@ -12,8 +14,23 @@ class LogEvent
public readonly ?string $source = null,
public readonly ?string $origin = null,
public readonly array $context = [],
public readonly ?DateTime $date = null,
)
{
}
public function jsonSerialize(): mixed
{
return [
'brief' => $this->brief,
'detail' => $this->detail,
'level' => $this->level,
'scope' => $this->scope,
'source' => $this->source,
'origin' => $this->origin,
'context' => $this->context,
'date' => $this->date?->format('Y-m-d H:i:s P'),
];
}
}