#feature: update log format

This commit is contained in:
2026-01-19 14:21:15 +08:00
parent da3b05b7c0
commit 0646c8612b
7 changed files with 49 additions and 76 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Console\Commands;
use App\Services\JenkinsMonitorService;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
class JenkinsMonitorCommand extends Command
{
@@ -13,29 +14,29 @@ class JenkinsMonitorCommand extends Command
public function handle(JenkinsMonitorService $service): void
{
$this->info('开始检查 Jenkins 构建...');
Log::info('开始检查 Jenkins 构建...');
$results = $service->checkAllProjects();
if (isset($results['skipped'])) {
$this->warn('跳过检查: ' . ($results['reason'] ?? 'unknown'));
Log::warning('跳过检查: ' . ($results['reason'] ?? 'unknown'));
return;
}
foreach ($results as $slug => $result) {
if (isset($result['skipped'])) {
$this->line(sprintf('[%s] 跳过: %s', $slug, $result['reason'] ?? 'unknown'));
Log::info(sprintf('[%s] 跳过: %s', $slug, $result['reason'] ?? 'unknown'));
continue;
}
$newBuilds = $result['new_builds'] ?? [];
if (empty($newBuilds)) {
$this->line(sprintf('[%s] 无新构建', $slug));
Log::info(sprintf('[%s] 无新构建', $slug));
} else {
$this->info(sprintf('[%s] 发现 %d 个新构建: #%s', $slug, count($newBuilds), implode(', #', $newBuilds)));
Log::info(sprintf('[%s] 发现 %d 个新构建: #%s', $slug, count($newBuilds), implode(', #', $newBuilds)));
}
}
$this->info('检查完成');
Log::info('检查完成');
}
}