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;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,10 @@ class CurateJobs extends Command
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$log = Log::channel('jobs_curate');
|
||||
|
||||
$this->info('Starting job curation...');
|
||||
$log->info('Starting job curation batch', ['batch_size' => $batchSize]);
|
||||
$this->newLine();
|
||||
|
||||
// Fetch uncurated jobs
|
||||
@@ -72,11 +75,14 @@ class CurateJobs extends Command
|
||||
'stream' => false,
|
||||
'prompt' => $body,
|
||||
]);
|
||||
|
||||
var_dump($response->json());
|
||||
|
||||
if ($response->successful()) {
|
||||
|
||||
$responseArray = $response->json();
|
||||
$responseTagsJson = $responseArray['response'];
|
||||
Log::info("Curated job id: {$responseArray['job_id']} Result: {$responseTagsJson}");
|
||||
$log->info("Curated job id: {$job->id} Result: {$responseTagsJson}");
|
||||
$tags = json_decode($responseTagsJson, true);
|
||||
|
||||
if (empty($tags) || $tags === null) {
|
||||
@@ -111,11 +117,11 @@ class CurateJobs extends Command
|
||||
}
|
||||
} else {
|
||||
$failedCount++;
|
||||
Log::warning("Failed to curate job #{$job->id}: API returned {$response->status()}");
|
||||
$log->warning("Failed to curate job #{$job->id}: API returned {$response->status()} -> {$response->body()}");
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$failedCount++;
|
||||
Log::error("Error curating job #{$job->id}: {$e->getMessage()}");
|
||||
$log->error("Error curating job #{$job->id}: {$e->getMessage()}");
|
||||
}
|
||||
|
||||
$progressBar->advance();
|
||||
@@ -125,6 +131,7 @@ class CurateJobs extends Command
|
||||
$this->newLine(2);
|
||||
|
||||
$this->info("Successfully curated {$curatedCount} jobs.");
|
||||
$log->info("Curation complete", ['curated' => $curatedCount, 'failed' => $failedCount]);
|
||||
|
||||
if ($failedCount > 0) {
|
||||
$this->warn("Failed to curate {$failedCount} jobs. Check logs for details.");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Services\JobEnrichmentService;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
#[Signature('jobs:enrich {--batch=100}')]
|
||||
#[Description('Enrich job listings with additional data (categories, experience levels, etc.)')]
|
||||
@@ -27,6 +28,9 @@ class EnrichJobs extends Command
|
||||
{
|
||||
$batchSize = (int) $this->option('batch');
|
||||
|
||||
$log = Log::channel('jobs_enrich');
|
||||
$log->info('Starting job enrichment', ['batch_size' => $batchSize]);
|
||||
|
||||
$this->info('Enriching job listings...');
|
||||
$this->newLine();
|
||||
|
||||
@@ -34,6 +38,7 @@ class EnrichJobs extends Command
|
||||
|
||||
$this->newLine();
|
||||
$this->info("Enriched {$enrichedCount} jobs successfully!");
|
||||
$log->info('Enrichment complete', ['enriched' => $enrichedCount]);
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Models\JobSource;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
#[Signature('jobs:fetch {source?} {--limit=50} {--sync}')]
|
||||
#[Description('Fetch jobs from API sources and queue them for processing')]
|
||||
@@ -24,25 +25,28 @@ class FetchJobs extends Command
|
||||
$limit = (int) $this->option('limit');
|
||||
$sync = $this->option('sync');
|
||||
|
||||
$log = Log::channel('jobs_fetch');
|
||||
$log->info('Starting job fetch command', ['source' => $sourceName, 'limit' => $limit, 'sync' => $sync]);
|
||||
|
||||
$this->info('Starting job fetch process...');
|
||||
$this->newLine();
|
||||
|
||||
try {
|
||||
if ($sourceName) {
|
||||
// Fetch from specific source
|
||||
$this->fetchFromSource($sourceName, $limit, $sync);
|
||||
} else {
|
||||
// Fetch from all active sources
|
||||
$this->fetchFromAllSources($limit, $sync);
|
||||
}
|
||||
|
||||
$this->newLine();
|
||||
$this->info('Job fetch process completed!');
|
||||
$log->info('Job fetch command completed');
|
||||
|
||||
return self::SUCCESS;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->error("Failed to fetch jobs: {$e->getMessage()}");
|
||||
$log->error('Job fetch command failed', ['error' => $e->getMessage()]);
|
||||
return self::FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
#[Signature('jobs:summary {--batch=50}')]
|
||||
#[Description('Command description')]
|
||||
@@ -18,12 +19,24 @@ class GenerateJobSummaryCommand extends Command
|
||||
public function handle()
|
||||
{
|
||||
$batchSize = (int) $this->option('batch');
|
||||
$log = Log::channel('jobs_summary');
|
||||
$log->info('Starting summary generation', ['batch_size' => $batchSize]);
|
||||
|
||||
$jobs = $this->getJobs($batchSize);
|
||||
$processed = 0;
|
||||
$failed = 0;
|
||||
|
||||
foreach ($jobs as $job) {
|
||||
$this->processJob($job);
|
||||
try {
|
||||
$this->processJob($job);
|
||||
$processed++;
|
||||
} catch (\Exception $e) {
|
||||
$failed++;
|
||||
$log->error("Failed to generate summary for job #{$job->id}", ['error' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
$log->info('Summary generation complete', ['processed' => $processed, 'failed' => $failed]);
|
||||
}
|
||||
|
||||
private function getJobs(int $batchSize)
|
||||
|
||||
Reference in New Issue
Block a user