#feature: update log format

This commit is contained in:
2026-01-19 15:42:44 +08:00
parent 0646c8612b
commit ddd0f531fd
9 changed files with 180 additions and 170 deletions

View File

@@ -14,29 +14,29 @@ class JenkinsMonitorCommand extends Command
public function handle(JenkinsMonitorService $service): void
{
Log::info('开始检查 Jenkins 构建...');
Log::channel('jenkins-monitor')->info('开始检查 Jenkins 构建...');
$results = $service->checkAllProjects();
if (isset($results['skipped'])) {
Log::warning('跳过检查: ' . ($results['reason'] ?? 'unknown'));
Log::channel('jenkins-monitor')->warning('跳过检查: ' . ($results['reason'] ?? 'unknown'));
return;
}
foreach ($results as $slug => $result) {
if (isset($result['skipped'])) {
Log::info(sprintf('[%s] 跳过: %s', $slug, $result['reason'] ?? 'unknown'));
Log::channel('jenkins-monitor')->info(sprintf('[%s] 跳过: %s', $slug, $result['reason'] ?? 'unknown'));
continue;
}
$newBuilds = $result['new_builds'] ?? [];
if (empty($newBuilds)) {
Log::info(sprintf('[%s] 无新构建', $slug));
Log::channel('jenkins-monitor')->info(sprintf('[%s] 无新构建', $slug));
} else {
Log::info(sprintf('[%s] 发现 %d 个新构建: #%s', $slug, count($newBuilds), implode(', #', $newBuilds)));
Log::channel('jenkins-monitor')->info(sprintf('[%s] 发现 %d 个新构建: #%s', $slug, count($newBuilds), implode(', #', $newBuilds)));
}
}
Log::info('检查完成');
Log::channel('jenkins-monitor')->info('检查完成');
}
}