info("Fetching jobs from source: {$this->source->name}"); try { $client = JobApiClientFactory::make($this->source); $jobsData = $client->fetchJobs($this->params); $log->info("Fetched {count} jobs from {source}", [ 'count' => count($jobsData), 'source' => $this->source->name, ]); foreach ($jobsData as $jobData) { ProcessJobListing::dispatch($this->source, $jobData); } } catch (ApiException $e) { $log->error("API error fetching jobs from {source}", [ 'source' => $this->source->name, 'error' => $e->getMessage(), 'context' => $e->getContext(), ]); if ($e instanceof \App\Services\JobApi\Exceptions\RateLimitException) { if ($e->retryAfter && $e->retryAfter > 3600) { $this->fail($e); return; } } throw $e; } catch (\Exception $e) { $log->error("Unexpected error fetching jobs from {source}", [ 'source' => $this->source->name, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString(), ]); throw $e; } } public function failed(\Throwable $exception): void { Log::channel('jobs_fetch')->error("Failed to fetch jobs from {source} after {tries} attempts", [ 'source' => $this->source->name, 'tries' => $this->tries, 'error' => $exception->getMessage(), ]); } }