feat: log to database

This commit is contained in:
Björn Fromme
2025-04-25 08:31:45 +02:00
parent 8d1edc3da0
commit 9094e8c061
7 changed files with 288 additions and 0 deletions
+102
View File
@@ -0,0 +1,102 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'core_log_entry')]
#[ORM\Entity]
class LogEntry
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(type: 'string', length: 255)]
private ?string $channel;
#[ORM\Column(type: 'string', length: 255)]
private ?string $message;
#[ORM\Column(type: 'json', nullable: true)]
private ?array $context = [];
#[ORM\Column(type: 'json', nullable: true)]
private ?array $extra = [];
#[ORM\Column(type: 'datetime_immutable')]
private \DateTimeImmutable $createdAt;
public function __construct(string $channel, string $message)
{
$this->channel = $channel;
$this->message = $message;
$this->createdAt = new \DateTimeImmutable('now');
}
public function getId(): ?int
{
return $this->id;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setMessage(string $message): self
{
$this->message = $message;
return $this;
}
public function getChannel(): ?string
{
return $this->channel;
}
public function setChannel(?string $channel): self
{
$this->channel = $channel;
return $this;
}
public function getContext(): ?array
{
return $this->context;
}
public function setContext(?array $context): self
{
$this->context = $context;
return $this;
}
public function getExtra(): ?array
{
return $this->extra;
}
public function setExtra(?array $extra): self
{
$this->extra = $extra;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
}