Skip to content

Commit bdaf693

Browse files
committed
Refine structured command logging
1 parent 35380c1 commit bdaf693

58 files changed

Lines changed: 394 additions & 242 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Console/Command/AgentsCommand.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use FastForward\DevTools\Filesystem\FilesystemInterface;
2525
use FastForward\DevTools\Path\DevToolsPathResolver;
2626
use FastForward\DevTools\Sync\PackagedDirectorySynchronizer;
27-
use Psr\Log\LoggerInterface;
2827
use Symfony\Component\Console\Attribute\AsCommand;
2928
use Symfony\Component\Console\Command\Command;
3029
use Symfony\Component\Console\Input\InputInterface;
@@ -48,12 +47,10 @@ final class AgentsCommand extends Command
4847
/**
4948
* @param PackagedDirectorySynchronizer $synchronizer
5049
* @param FilesystemInterface $filesystem
51-
* @param LoggerInterface $logger
5250
*/
5351
public function __construct(
5452
private readonly PackagedDirectorySynchronizer $synchronizer,
5553
private readonly FilesystemInterface $filesystem,
56-
private readonly LoggerInterface $logger,
5754
) {
5855
parent::__construct();
5956
}

src/Console/Command/ChangelogCheckCommand.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use FastForward\DevTools\Changelog\Checker\UnreleasedEntryCheckerInterface;
2424
use FastForward\DevTools\Console\Input\HasJsonOption;
2525
use FastForward\DevTools\Filesystem\FilesystemInterface;
26-
use Psr\Log\LoggerInterface;
2726
use Symfony\Component\Console\Attribute\AsCommand;
2827
use Symfony\Component\Console\Command\Command;
2928
use Symfony\Component\Console\Input\InputInterface;
@@ -45,12 +44,10 @@ final class ChangelogCheckCommand extends Command
4544
/**
4645
* @param FilesystemInterface $filesystem
4746
* @param UnreleasedEntryCheckerInterface $unreleasedEntryChecker
48-
* @param LoggerInterface $logger
4947
*/
5048
public function __construct(
5149
private readonly FilesystemInterface $filesystem,
5250
private readonly UnreleasedEntryCheckerInterface $unreleasedEntryChecker,
53-
private readonly LoggerInterface $logger,
5451
) {
5552
parent::__construct();
5653
}

src/Console/Command/ChangelogEntryCommand.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use FastForward\DevTools\Changelog\Manager\ChangelogManagerInterface;
2626
use FastForward\DevTools\Console\Input\HasJsonOption;
2727
use FastForward\DevTools\Filesystem\FilesystemInterface;
28-
use Psr\Log\LoggerInterface;
2928
use Symfony\Component\Console\Attribute\AsCommand;
3029
use Symfony\Component\Console\Command\Command;
3130
use Symfony\Component\Console\Input\InputArgument;
@@ -48,12 +47,10 @@ final class ChangelogEntryCommand extends Command
4847
/**
4948
* @param FilesystemInterface $filesystem
5049
* @param ChangelogManagerInterface $changelogManager
51-
* @param LoggerInterface $logger
5250
*/
5351
public function __construct(
5452
private readonly FilesystemInterface $filesystem,
5553
private readonly ChangelogManagerInterface $changelogManager,
56-
private readonly LoggerInterface $logger,
5754
) {
5855
parent::__construct();
5956
}

src/Console/Command/ChangelogNextVersionCommand.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use FastForward\DevTools\Changelog\Manager\ChangelogManagerInterface;
2525
use FastForward\DevTools\Console\Input\HasJsonOption;
2626
use FastForward\DevTools\Filesystem\FilesystemInterface;
27-
use Psr\Log\LoggerInterface;
2827
use Symfony\Component\Console\Attribute\AsCommand;
2928
use Symfony\Component\Console\Command\Command;
3029
use Symfony\Component\Console\Input\InputInterface;
@@ -46,12 +45,10 @@ final class ChangelogNextVersionCommand extends Command
4645
/**
4746
* @param FilesystemInterface $filesystem
4847
* @param ChangelogManagerInterface $changelogManager
49-
* @param LoggerInterface $logger
5048
*/
5149
public function __construct(
5250
private readonly FilesystemInterface $filesystem,
5351
private readonly ChangelogManagerInterface $changelogManager,
54-
private readonly LoggerInterface $logger,
5552
) {
5653
parent::__construct();
5754
}

src/Console/Command/ChangelogPromoteCommand.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use FastForward\DevTools\Console\Input\HasJsonOption;
2626
use FastForward\DevTools\Filesystem\FilesystemInterface;
2727
use Psr\Clock\ClockInterface;
28-
use Psr\Log\LoggerInterface;
2928
use Symfony\Component\Console\Attribute\AsCommand;
3029
use Symfony\Component\Console\Command\Command;
3130
use Symfony\Component\Console\Input\InputArgument;
@@ -49,13 +48,11 @@ final class ChangelogPromoteCommand extends Command
4948
* @param FilesystemInterface $filesystem
5049
* @param ChangelogManagerInterface $changelogManager
5150
* @param ClockInterface $clock
52-
* @param LoggerInterface $logger
5351
*/
5452
public function __construct(
5553
private readonly FilesystemInterface $filesystem,
5654
private readonly ChangelogManagerInterface $changelogManager,
5755
private readonly ClockInterface $clock,
58-
private readonly LoggerInterface $logger,
5956
) {
6057
parent::__construct();
6158
}

src/Console/Command/ChangelogShowCommand.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use FastForward\DevTools\Changelog\Manager\ChangelogManagerInterface;
2525
use FastForward\DevTools\Console\Input\HasJsonOption;
2626
use FastForward\DevTools\Filesystem\FilesystemInterface;
27-
use Psr\Log\LoggerInterface;
2827
use Symfony\Component\Console\Attribute\AsCommand;
2928
use Symfony\Component\Console\Command\Command;
3029
use Symfony\Component\Console\Input\InputArgument;
@@ -44,12 +43,10 @@ final class ChangelogShowCommand extends Command
4443
/**
4544
* @param FilesystemInterface $filesystem
4645
* @param ChangelogManagerInterface $changelogManager
47-
* @param LoggerInterface $logger
4846
*/
4947
public function __construct(
5048
private readonly FilesystemInterface $filesystem,
5149
private readonly ChangelogManagerInterface $changelogManager,
52-
private readonly LoggerInterface $logger,
5350
) {
5451
parent::__construct();
5552
}

src/Console/Command/CodeOwnersCommand.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use FastForward\DevTools\CodeOwners\CodeOwnersGenerator;
2525
use FastForward\DevTools\Filesystem\FilesystemInterface;
2626
use FastForward\DevTools\Resource\FileDiffer;
27-
use Psr\Log\LoggerInterface;
2827
use Psr\Log\LogLevel;
2928
use Symfony\Component\Console\Attribute\AsCommand;
3029
use Symfony\Component\Console\Command\Command;
@@ -53,14 +52,12 @@ final class CodeOwnersCommand extends Command
5352
* @param CodeOwnersGenerator $generator the generator used to infer and render CODEOWNERS contents
5453
* @param FilesystemInterface $filesystem the filesystem used to read and write the target file
5554
* @param FileDiffer $fileDiffer the differ used to report managed-file drift
56-
* @param LoggerInterface $logger the output-aware logger
5755
* @param SymfonyStyle $io the SymfonyStyle instance for interactive prompts
5856
*/
5957
public function __construct(
6058
private readonly CodeOwnersGenerator $generator,
6159
private readonly FilesystemInterface $filesystem,
6260
private readonly FileDiffer $fileDiffer,
63-
private readonly LoggerInterface $logger,
6461
private readonly SymfonyStyle $io,
6562
) {
6663
parent::__construct();
@@ -153,21 +150,22 @@ protected function execute(InputInterface $input, OutputInterface $output): int
153150
: \sprintf('Updating managed file %s from generated CODEOWNERS content.', $targetPath),
154151
);
155152

156-
$this->notice($comparison->getSummary(), $input, [
153+
$this->log($comparison->getSummary(), $input, [
157154
'target_path' => $targetPath,
158-
]);
155+
], LogLevel::NOTICE);
159156

160157
if ($comparison->isChanged()) {
161158
$consoleDiff = $this->fileDiffer->formatForConsole($comparison->getDiff(), $output->isDecorated());
162159

163160
if (null !== $consoleDiff) {
164-
$this->notice(
161+
$this->log(
165162
$consoleDiff,
166163
$input,
167164
[
168165
'target_path' => $targetPath,
169166
'diff' => $comparison->getDiff(),
170167
],
168+
LogLevel::NOTICE,
171169
);
172170
}
173171
}

src/Console/Command/CodeStyleCommand.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use FastForward\DevTools\Path\DevToolsPathResolver;
2525
use FastForward\DevTools\Process\ProcessBuilderInterface;
2626
use FastForward\DevTools\Process\ProcessQueueInterface;
27-
use Psr\Log\LoggerInterface;
2827
use Symfony\Component\Config\FileLocatorInterface;
2928
use Symfony\Component\Console\Attribute\AsCommand;
3029
use Symfony\Component\Console\Command\Command;
@@ -63,13 +62,11 @@ final class CodeStyleCommand extends Command
6362
* @param FileLocatorInterface $fileLocator locates the configuration file required by EasyCodingStandard
6463
* @param ProcessBuilderInterface $processBuilder builds the process instances used to execute Composer and ECS commands
6564
* @param ProcessQueueInterface $processQueue queues and executes the generated processes in the required order
66-
* @param LoggerInterface $logger logs command feedback
6765
*/
6866
public function __construct(
6967
private readonly FileLocatorInterface $fileLocator,
7068
private readonly ProcessBuilderInterface $processBuilder,
7169
private readonly ProcessQueueInterface $processQueue,
72-
private readonly LoggerInterface $logger,
7370
) {
7471
parent::__construct();
7572
}

src/Console/Command/CopyResourceCommand.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use FastForward\DevTools\Filesystem\FinderFactoryInterface;
2525
use FastForward\DevTools\Filesystem\FilesystemInterface;
2626
use FastForward\DevTools\Resource\FileDiffer;
27-
use Psr\Log\LoggerInterface;
2827
use Psr\Log\LogLevel;
2928
use Symfony\Component\Config\FileLocatorInterface;
3029
use Symfony\Component\Console\Attribute\AsCommand;
@@ -56,15 +55,13 @@ final class CopyResourceCommand extends Command
5655
* @param FileLocatorInterface $fileLocator the locator used to resolve source resources
5756
* @param FinderFactoryInterface $finderFactory the factory used to create finders for directory resources
5857
* @param FileDiffer $fileDiffer the service used to summarize overwrite changes
59-
* @param LoggerInterface $logger the output-aware logger
6058
* @param SymfonyStyle $io the input/output service used to interact with the user
6159
*/
6260
public function __construct(
6361
private readonly FilesystemInterface $filesystem,
6462
private readonly FileLocatorInterface $fileLocator,
6563
private readonly FinderFactoryInterface $finderFactory,
6664
private readonly FileDiffer $fileDiffer,
67-
private readonly LoggerInterface $logger,
6865
private readonly SymfonyStyle $io,
6966
) {
7067
parent::__construct();
@@ -162,11 +159,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
162159
* @param string $sourcePath the resolved source directory
163160
* @param string $targetPath the resolved target directory
164161
* @param bool $overwrite whether existing files MAY be overwritten
162+
* @param bool $dryRun whether the command is previewing changes only
163+
* @param bool $check whether the command SHOULD fail on detected drift
164+
* @param bool $interactive whether the command SHOULD prompt before overwriting drifted files
165+
* @param InputInterface $input the originating command input
165166
* @param OutputInterface $output the output used to report copy results
166-
* @param bool $dryRun
167-
* @param bool $check
168-
* @param bool $interactive
169-
* @param InputInterface $input
170167
*
171168
* @return int the command status code
172169
*/
@@ -213,11 +210,11 @@ private function copyDirectory(
213210
* @param string $sourcePath the resolved source file
214211
* @param string $targetPath the resolved target file
215212
* @param bool $overwrite whether an existing target file MAY be overwritten
213+
* @param bool $dryRun whether the command is previewing changes only
214+
* @param bool $check whether the command SHOULD fail on detected drift
215+
* @param bool $interactive whether the command SHOULD prompt before overwriting drifted files
216+
* @param InputInterface $input the originating command input
216217
* @param OutputInterface $output the output used to report copy results
217-
* @param bool $dryRun
218-
* @param bool $check
219-
* @param bool $interactive
220-
* @param InputInterface $input
221218
*
222219
* @return int the command status code
223220
*/
@@ -246,27 +243,29 @@ private function copyFile(
246243
if (($overwrite || $dryRun || $check || $interactive) && $this->filesystem->exists($targetPath)) {
247244
$comparison = $this->fileDiffer->diff($sourcePath, $targetPath);
248245

249-
$this->notice(
246+
$this->log(
250247
$comparison->getSummary(),
251248
$input,
252249
[
253250
'source_path' => $sourcePath,
254251
'target_path' => $targetPath,
255252
],
253+
LogLevel::NOTICE,
256254
);
257255

258256
if ($comparison->isChanged()) {
259257
$consoleDiff = $this->fileDiffer->formatForConsole($comparison->getDiff(), $output->isDecorated());
260258

261259
if (null !== $consoleDiff) {
262-
$this->notice(
260+
$this->log(
263261
$consoleDiff,
264262
$input,
265263
[
266264
'source_path' => $sourcePath,
267265
'target_path' => $targetPath,
268266
'diff' => $comparison->getDiff(),
269267
],
268+
LogLevel::NOTICE,
270269
);
271270
}
272271
}

src/Console/Command/DependenciesCommand.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
use FastForward\DevTools\Process\ProcessBuilderInterface;
2727
use FastForward\DevTools\Process\ProcessQueueInterface;
2828
use InvalidArgumentException;
29-
use Psr\Log\LoggerInterface;
3029
use Symfony\Component\Config\FileLocatorInterface;
3130
use Symfony\Component\Console\Attribute\AsCommand;
3231
use Symfony\Component\Console\Command\Command;
@@ -61,13 +60,11 @@ final class DependenciesCommand extends Command
6160
* @param ProcessBuilderInterface $processBuilder creates analyzer and upgrade processes
6261
* @param ProcessQueueInterface $processQueue executes queued processes
6362
* @param FileLocatorInterface $fileLocator resolves the dependency analyser configuration
64-
* @param LoggerInterface $logger writes command feedback
6563
*/
6664
public function __construct(
6765
private readonly ProcessBuilderInterface $processBuilder,
6866
private readonly ProcessQueueInterface $processQueue,
6967
private readonly FileLocatorInterface $fileLocator,
70-
private readonly LoggerInterface $logger,
7168
) {
7269
return parent::__construct();
7370
}

0 commit comments

Comments
 (0)