specific log files for commands and jobs
This commit is contained in:
@@ -33,33 +33,29 @@ class FetchJobsFromSource implements ShouldQueue
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
Log::info("Fetching jobs from source: {$this->source->name}");
|
||||
$log = Log::channel('jobs_fetch');
|
||||
$log->info("Fetching jobs from source: {$this->source->name}");
|
||||
|
||||
try {
|
||||
// Create API client for this source
|
||||
$client = JobApiClientFactory::make($this->source);
|
||||
|
||||
// Fetch jobs from the API
|
||||
$jobsData = $client->fetchJobs($this->params);
|
||||
|
||||
Log::info("Fetched {count} jobs from {source}", [
|
||||
$log->info("Fetched {count} jobs from {source}", [
|
||||
'count' => count($jobsData),
|
||||
'source' => $this->source->name,
|
||||
]);
|
||||
|
||||
// Dispatch individual jobs to process each job listing
|
||||
foreach ($jobsData as $jobData) {
|
||||
ProcessJobListing::dispatch($this->source, $jobData);
|
||||
}
|
||||
|
||||
} catch (ApiException $e) {
|
||||
Log::error("API error fetching jobs from {source}", [
|
||||
$log->error("API error fetching jobs from {source}", [
|
||||
'source' => $this->source->name,
|
||||
'error' => $e->getMessage(),
|
||||
'context' => $e->getContext(),
|
||||
]);
|
||||
|
||||
// Don't retry if it's a rate limit error with a long wait time
|
||||
if ($e instanceof \App\Services\JobApi\Exceptions\RateLimitException) {
|
||||
if ($e->retryAfter && $e->retryAfter > 3600) {
|
||||
$this->fail($e);
|
||||
@@ -70,7 +66,7 @@ class FetchJobsFromSource implements ShouldQueue
|
||||
throw $e;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Unexpected error fetching jobs from {source}", [
|
||||
$log->error("Unexpected error fetching jobs from {source}", [
|
||||
'source' => $this->source->name,
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
@@ -80,12 +76,9 @@ class FetchJobsFromSource implements ShouldQueue
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a job failure.
|
||||
*/
|
||||
public function failed(\Throwable $exception): void
|
||||
{
|
||||
Log::error("Failed to fetch jobs from {source} after {tries} attempts", [
|
||||
Log::channel('jobs_fetch')->error("Failed to fetch jobs from {source} after {tries} attempts", [
|
||||
'source' => $this->source->name,
|
||||
'tries' => $this->tries,
|
||||
'error' => $exception->getMessage(),
|
||||
|
||||
@@ -32,10 +32,11 @@ class ProcessJobListing implements ShouldQueue
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$log = Log::channel('jobs_process');
|
||||
|
||||
try {
|
||||
$fingerprint = $this->jobData->generateFingerprint();
|
||||
|
||||
// Check if job already exists by fingerprint or external_id
|
||||
$existingJob = Job::where('fingerprint', $fingerprint)
|
||||
->orWhere(function ($query) {
|
||||
$query->where('job_source_id', $this->source->id)
|
||||
@@ -44,7 +45,6 @@ class ProcessJobListing implements ShouldQueue
|
||||
->first();
|
||||
|
||||
if ($existingJob) {
|
||||
// Update existing job with fresh data
|
||||
$existingJob->update(array_merge(
|
||||
$this->jobData->toArray(),
|
||||
[
|
||||
@@ -53,9 +53,8 @@ class ProcessJobListing implements ShouldQueue
|
||||
]
|
||||
));
|
||||
|
||||
Log::debug("Updated existing job: {$this->jobData->title}");
|
||||
$log->debug("Updated existing job: {$this->jobData->title}");
|
||||
} else {
|
||||
// Create new job
|
||||
Job::create(array_merge(
|
||||
$this->jobData->toArray(),
|
||||
[
|
||||
@@ -64,11 +63,11 @@ class ProcessJobListing implements ShouldQueue
|
||||
]
|
||||
));
|
||||
|
||||
Log::debug("Created new job: {$this->jobData->title}");
|
||||
$log->debug("Created new job: {$this->jobData->title}");
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Failed to process job listing", [
|
||||
$log->error("Failed to process job listing", [
|
||||
'source' => $this->source->name,
|
||||
'external_id' => $this->jobData->externalId,
|
||||
'title' => $this->jobData->title,
|
||||
@@ -79,12 +78,9 @@ class ProcessJobListing implements ShouldQueue
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a job failure.
|
||||
*/
|
||||
public function failed(\Throwable $exception): void
|
||||
{
|
||||
Log::error("Failed to process job listing after {tries} attempts", [
|
||||
Log::channel('jobs_process')->error("Failed to process job listing after {tries} attempts", [
|
||||
'source' => $this->source->name,
|
||||
'external_id' => $this->jobData->externalId,
|
||||
'tries' => $this->tries,
|
||||
|
||||
Reference in New Issue
Block a user