specific log files for commands and jobs

This commit is contained in:
Doar Mihai
2026-05-02 01:40:46 +03:00
parent 792a598eda
commit 462eb2fc61
10 changed files with 138 additions and 31 deletions
+6 -10
View File
@@ -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,