Adicionando o serviço do RabbitMQ

production 0.2.0
José Neto 2 years ago
parent eea473fdaa
commit 4e876045da

@ -0,0 +1,37 @@
<?php
namespace Ae3\LaravelLogsLayer\app\Services;
use Ae3\LaravelLogsLayer\app\DataTransferObjects\ExceptionContextDTO;
use Throwable;
class RabbitMQLogService extends AbstractLogService
{
/**
* @inheritDoc
*/
protected function getLogChannel(): string
{
return 'rabbitmq';
}
/**
* @inheritDoc
*/
protected function buildLogData(string $caller, Throwable $exception, ExceptionContextDTO $contextDto): array
{
return [
'caller' => $caller,
'status_code' => $exception->getCode(),
'line' => $exception->getLine(),
'file' => $exception->getFile(),
'error_code' => $contextDto->code,
'custom_data' => $this->asPrettyJson($contextDto->custom_data),
'tags' => $contextDto->tags,
'exception' => get_class($exception),
'current_url' => $contextDto->current_url,
'current_user' => $this->asPrettyJson($contextDto->current_user),
'classes' => $this->asPrettyJson($this->getContextClasses($exception->getTrace(), $contextDto->root_namespace)),
];
}
}

@ -10,6 +10,7 @@ use Ae3\LaravelLogsLayer\app\Services\DailyLogService;
use Ae3\LaravelLogsLayer\app\Services\DiscordLogService;
use Ae3\LaravelLogsLayer\app\Services\EmailLogService;
use Ae3\LaravelLogsLayer\app\Services\LogstashLogService;
use Ae3\LaravelLogsLayer\app\Services\RabbitMQLogService;
use Hashids\Hashids;
use Illuminate\Support\Str;
use Throwable;
@ -52,6 +53,10 @@ trait LogTrait
if ($defaultChannel === 'email' || in_array('email', $stackChannels, true)) {
$this->logServices[] = app(EmailLogService::class);
}
if ($defaultChannel === 'rabbitmq' || in_array('rabbitmq', $stackChannels, true)) {
$this->logServices[] = app(RabbitMQLogService::class);
}
}
/**

Loading…
Cancel
Save