File: /home/xedaptot/ai.naniguide.com/app/Jobs/Concerns/LogsJobFailure.php
<?php
namespace App\Jobs\Concerns;
use Illuminate\Support\Facades\Log;
use Throwable;
/**
* Shared failed() callback for SendMessage and SendSingleMessage. Both jobs
* emit the same structured [JOB_FAILED] log line — ops scrapes this format,
* keep stable.
*
* The two jobs intentionally do not share an inheritance hierarchy (their
* constructor signatures are different); this trait is the minimal bit they
* actually share.
*/
trait LogsJobFailure
{
public function failed(Throwable $exception): void
{
Log::error('[JOB_FAILED] '.static::class, [
'exception' => $exception->getMessage(),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
'campaign_uid' => $this->campaign->uid ?? null,
'subscriber_email' => $this->subscriber->email ?? null,
]);
}
}