You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php
namespace App\Utilities\Logger;
use Throwable; use Carbon\Carbon; use Ramsey\Uuid\Uuid; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB;
class LogServiceRecordProcessor { public function __invoke($record) { try { $exception = json_decode($record['message'], true);
return array_merge($record, [ 'correlation_id' => Uuid::uuid4()->toString(), 'breadcrumbs' => DB::getQueryLog(), 'request' => app('request'), 'message' => Arr::get($exception, 'getMessage', $record['message']), 'from' => env('CONTAINER_NAME'), 'trace' => Arr::get($exception, 'getTraceAsString'), 'name' => Arr::get($exception, 'getName'), 'code' => Arr::get($exception, 'getCode'), 'file' => Arr::get($exception, 'getFile'), 'line' => Arr::get($exception, 'getLine'), 'user_id' => Auth::hasResolvedGuards() ? Auth::id() : null, 'created_at' => Carbon::now(), ]); } catch (Throwable $exception) { return $record; } } }
|