specific log files for commands and jobs
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user