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
+14 -1
View File
@@ -6,6 +6,7 @@ use App\Models\Job;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
#[Signature('jobs:clean {--days=30} {--force}')]
#[Description('Remove expired and old job listings from the database')]
@@ -22,6 +23,9 @@ class CleanJobs extends Command
$days = (int) $this->option('days');
$force = $this->option('force');
$log = Log::channel('jobs_clean');
$log->info('Starting job cleanup', ['days' => $days, 'force' => $force]);
$this->info("Cleaning job listings...");
$this->newLine();
@@ -35,11 +39,20 @@ class CleanJobs extends Command
$trashedCount = $this->cleanTrashedJobs($force);
$this->newLine();
$total = $expiredCount + $oldCount + $trashedCount;
$this->info("Cleanup Summary:");
$this->line(" • Expired jobs removed: {$expiredCount}");
$this->line(" • Old jobs removed (>{$days} days): {$oldCount}");
$this->line(" • Trashed jobs cleaned: {$trashedCount}");
$this->line(" • Total removed: " . ($expiredCount + $oldCount + $trashedCount));
$this->line(" • Total removed: {$total}");
$log->info('Cleanup complete', [
'expired' => $expiredCount,
'old' => $oldCount,
'trashed' => $trashedCount,
'total' => $total,
]);
return self::SUCCESS;
}