Skip to content

Commit 37b5ba1

Browse files
committed
[console] Suppress structured progress preambles
1 parent 36e4a77 commit 37b5ba1

21 files changed

Lines changed: 210 additions & 48 deletions

src/Console/Command/CodeStyleCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
121121
$fix = (bool) $input->getOption('fix');
122122
$progress = ! $jsonOutput && (bool) $input->getOption('progress');
123123

124-
$this->logger->info('Running code style checks and fixes...');
124+
$this->intermediateInfo('Running code style checks and fixes...', $input);
125125

126126
$composerUpdate = $this->processBuilder
127127
->withArgument('--lock')

src/Console/Command/DependenciesCommand.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
150150
);
151151
}
152152

153-
if (! $jsonOutput) {
154-
$this->logger->info('Running dependency analysis...', [
155-
'input' => $input,
156-
]);
157-
}
153+
$this->intermediateInfo('Running dependency analysis...', $input);
158154

159155
$this->processQueue->add(
160156
process: $this->getComposerDependencyAnalyserCommand($input),

src/Console/Command/DocsCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
155155
$template = DevToolsPathResolver::getPreferredVendorPath(self::DEFAULT_TEMPLATE);
156156
}
157157

158-
$this->logger->info('Generating API documentation...', [
159-
'input' => $input,
160-
]);
158+
$this->intermediateInfo('Generating API documentation...', $input);
161159

162160
if (
163161
! $projectCapabilities->hasGuideDirectory()

src/Console/Command/MetricsCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
135135
$exclude = (string) $input->getOption('exclude');
136136
$junit = $input->getOption('junit');
137137

138-
$this->logger->info('Running code metrics analysis...', [
139-
'input' => $input,
140-
]);
138+
$this->intermediateInfo('Running code metrics analysis...', $input);
141139

142140
$processBuilder = $this->processBuilder
143141
->withArgument('--ansi')

src/Console/Command/PhpDocCommand.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
152152
$progress = ! $jsonOutput && (bool) $input->getOption('progress');
153153
$cacheEnabled = $this->isCacheEnabled($input);
154154

155-
$this->logger->info('Checking and fixing PHPDocs...', [
156-
'input' => $input,
157-
]);
155+
$this->intermediateInfo('Checking and fixing PHPDocs...', $input);
158156

159-
$this->ensureDocHeaderExists();
157+
$this->ensureDocHeaderExists($input);
160158

161159
$processBuilder = $this->processBuilder
162160
->withArgument('--ansi')
@@ -231,9 +229,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
231229
* The method MUST query the local filesystem. If the file is missing, it SHOULD copy
232230
* the tool template into the root folder.
233231
*
232+
* @param InputInterface $input the originating command input
233+
*
234234
* @return void
235235
*/
236-
private function ensureDocHeaderExists(): void
236+
private function ensureDocHeaderExists(InputInterface $input): void
237237
{
238238
$support = $this->composer->getSupport();
239239

@@ -265,6 +265,6 @@ private function ensureDocHeaderExists(): void
265265
return;
266266
}
267267

268-
$this->logger->info('Created .docheader from repository template.');
268+
$this->intermediateInfo('Created .docheader from repository template.', $input);
269269
}
270270
}

src/Console/Command/RefactorCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
120120
$fix = (bool) $input->getOption('fix');
121121
$progress = ! $jsonOutput && (bool) $input->getOption('progress');
122122

123-
$this->logger->info('Running Rector for code refactoring...', [
124-
'input' => $input,
125-
]);
123+
$this->intermediateInfo('Running Rector for code refactoring...', $input);
126124

127125
$processBuilder = $this->processBuilder
128126
->withArgument('--ansi')

src/Console/Command/ReportsCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
129129
$coveragePath = (string) $input->getOption('coverage');
130130
$metricsPath = (string) $input->getOption('metrics');
131131

132-
$this->logger->info('Generating frontpage for Fast Forward documentation...', [
133-
'input' => $input,
134-
]);
132+
$this->intermediateInfo('Generating frontpage for Fast Forward documentation...', $input);
135133

136134
$docsBuilder = $this->processBuilder
137135
->withArgument('--target', $target);

src/Console/Command/StandardsCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
109109
$commands = [];
110110
$fix = (bool) $input->getOption('fix');
111111

112-
$this->logger->info('Running code standards checks...', [
113-
'input' => $input,
114-
]);
112+
$this->intermediateInfo('Running code standards checks...', $input);
115113

116114
foreach (['refactor', 'phpdoc', 'code-style', 'reports'] as $command) {
117115
$commands[] = $command;

src/Console/Command/SyncCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
112112
];
113113
$allowDetached = ! $dryRun && ! $check && ! $interactive;
114114

115-
$this->logger->info('Starting dev-tools synchronization...', [
116-
'input' => $input,
117-
]);
115+
$this->intermediateInfo('Starting dev-tools synchronization...', $input);
118116

119117
$this->queueDevToolsCommand(['update-composer-json', ...$modeArguments], false, $jsonOutput, $prettyJsonOutput);
120118
$this->queueDevToolsCommand(['funding', ...$modeArguments], false, $jsonOutput, $prettyJsonOutput);

src/Console/Command/Traits/LogsCommandResults.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,28 @@ trait LogsCommandResults
3434
{
3535
use HasCommandLogger;
3636

37+
/**
38+
* Logs a non-terminal informational message unless structured JSON output is active.
39+
*
40+
* @param string $message the progress message
41+
* @param InputInterface $input the originating command input
42+
* @param array<string, mixed> $context optional extra log context
43+
*
44+
* @return void
45+
*/
46+
private function intermediateInfo(string $message, InputInterface $input, array $context = []): void
47+
{
48+
if (method_exists($this, 'isJsonOutput') && $this->isJsonOutput($input)) {
49+
return;
50+
}
51+
52+
$this->getLogger()
53+
->info($message, [
54+
'input' => $input,
55+
...$context,
56+
]);
57+
}
58+
3759
/**
3860
* Logs an informational command message at notice level.
3961
*

0 commit comments

Comments
 (0)