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
+8 -1
View File
@@ -7,6 +7,7 @@ use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
#[Signature('jobs:deduplicate {--dry-run}')]
#[Description('Find and remove duplicate job listings based on fingerprint')]
@@ -21,6 +22,8 @@ class DeduplicateJobs extends Command
public function handle(): int
{
$dryRun = $this->option('dry-run');
$log = Log::channel('jobs_deduplicate');
$log->info('Starting deduplication', ['dry_run' => $dryRun]);
$this->info('Searching for duplicate job listings...');
$this->newLine();
@@ -30,6 +33,7 @@ class DeduplicateJobs extends Command
if ($duplicates->isEmpty()) {
$this->info('No duplicates found!');
$log->info('No duplicates found');
return self::SUCCESS;
}
@@ -67,10 +71,13 @@ class DeduplicateJobs extends Command
}
if ($dryRun) {
$this->info("Dry run completed. Would remove {$this->countDuplicatesToRemove($duplicates)} duplicate jobs.");
$wouldRemove = $this->countDuplicatesToRemove($duplicates);
$this->info("Dry run completed. Would remove {$wouldRemove} duplicate jobs.");
$this->line('Run without --dry-run to actually remove them.');
$log->info('Dry run complete', ['would_remove' => $wouldRemove]);
} else {
$this->info("Removed {$removedCount} duplicate jobs.");
$log->info('Deduplication complete', ['removed' => $removedCount]);
}
return self::SUCCESS;