<?php
namespace App\Entity\Log;
use App\Entity\AbstractEntity;
use App\Repository\Log\RequestLogRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: RequestLogRepository::class)]
#[ORM\Table(name: 'request_logs')]
#[ORM\Index(columns: ['created_at'], name: 'request_logs_created_at_idx')]
#[ORM\Index(columns: ['uri'], name: 'request_logs_uri_idx')]
#[ORM\Index(columns: ['service_name'], name: 'service_name_idx')]
#[ORM\Index(columns: ['object_ref'], name: 'object_ref_idx')]
#[ORM\Index(columns: ['status_code'], name: 'request_logs_status_code_idx')]
class RequestLog extends AbstractEntity
{
#[ORM\Column(name: 'service_name', type: 'string', length: 50, nullable: true)]
private ?string $serviceName = null;
#[ORM\Column(name: 'object_ref', type: 'string', length: 36, nullable: true)]
private ?string $objectRef = null;
#[ORM\Column(name: 'method', type: 'string', length: 10, nullable: false)]
private string $method;
#[ORM\Column(name: 'uri', type: 'string', nullable: false)]
private string $uri;
#[ORM\Column(name: 'status_code', type: 'integer', nullable: false)]
private int $statusCode = 200;
#[ORM\Column(name: 'headers', type: 'json', nullable: true)]
private string|array|null $headers = null;
#[ORM\Column(name: 'query_params', type: 'json', nullable: true)]
private string|array|null $queryParams = null;
#[ORM\Column(name: 'body_params', type: 'json', nullable: true)]
private string|array|null $bodyParams = null;
#[ORM\Column(name: 'response_body', type: 'json', nullable: true)]
private string|array|null $responseBody = null;
#[ORM\Column(name: 'exception', type: 'text', nullable: true)]
private string|array|null $exception = null;
#[ORM\Column(name: 'request_duration', type: 'float', nullable: true)]
private ?float $requestDuration = null;
public function __toString(): string
{
return sprintf('%s %s', $this->method, $this->uri);
}
public function getServiceName(): ?string
{
return $this->serviceName;
}
public function setServiceName(?string $serviceName): void
{
$this->serviceName = $serviceName;
}
public function getMethod(): string
{
return $this->method;
}
public function setMethod(string $method): void
{
$this->method = $method;
}
public function getUri(): string
{
return $this->uri;
}
public function setUri(string $uri): void
{
$this->uri = $uri;
}
public function getStatusCode(): int
{
return $this->statusCode;
}
public function setStatusCode(int $statusCode): void
{
$this->statusCode = $statusCode;
}
public function getHeaders(): string|array|null
{
return $this->headers;
}
public function setHeaders(string|array|null $headers): void
{
$this->headers = $headers;
}
public function getQueryParams(): array|string|null
{
return $this->queryParams;
}
public function setQueryParams(array|string|null $queryParams): void
{
$this->queryParams = $queryParams;
}
public function getBodyParams(): array|string|null
{
return $this->bodyParams;
}
public function setBodyParams(array|string|null $bodyParams): void
{
$this->bodyParams = $bodyParams;
}
public function getResponseBody(): array|string|null
{
return $this->responseBody;
}
public function setResponseBody(array|string|null $responseBody): void
{
$this->responseBody = $responseBody;
}
public function getException(): array|string|null
{
return $this->exception;
}
public function setException(array|string|null $exception): void
{
$this->exception = $exception;
}
public function getRequestDuration(): ?float
{
return $this->requestDuration;
}
public function setRequestDuration(?float $requestDuration): void
{
$this->requestDuration = $requestDuration;
}
public function getObjectRef(): ?string
{
return $this->objectRef;
}
public function setObjectRef(?string $objectRef): void
{
$this->objectRef = $objectRef;
}
}