humbug /
box
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /* |
||
| 6 | * This file is part of the box project. |
||
| 7 | * |
||
| 8 | * (c) Kevin Herrera <[email protected]> |
||
| 9 | * Théo Fidry <[email protected]> |
||
| 10 | * |
||
| 11 | * This source file is subject to the MIT license that is bundled |
||
| 12 | * with this source code in the file LICENSE. |
||
| 13 | */ |
||
| 14 | |||
| 15 | namespace KevinGH\Box\Console\Logger; |
||
| 16 | |||
| 17 | use Psr\Log\AbstractLogger; |
||
| 18 | use Psr\Log\LogLevel; |
||
| 19 | use Stringable; |
||
| 20 | use Symfony\Component\Console\Output\OutputInterface; |
||
| 21 | use function array_key_exists; |
||
| 22 | |||
| 23 | final class CompilerPsrLogger extends AbstractLogger |
||
| 24 | { |
||
| 25 | public function __construct( |
||
| 26 | private readonly CompilerLogger $decoratedLogger, |
||
|
0 ignored issues
–
show
|
|||
| 27 | ) { |
||
| 28 | } |
||
| 29 | |||
| 30 | public function log($level, string|Stringable $message, array $context = []): void |
||
| 31 | { |
||
| 32 | $verbosity = self::getVerbosity($level); |
||
| 33 | $output = self::getOutput($context); |
||
| 34 | |||
| 35 | if (null === $output) { |
||
| 36 | $this->decoratedLogger->log( |
||
| 37 | CompilerLogger::CHEVRON_PREFIX, |
||
| 38 | $message, |
||
| 39 | $verbosity, |
||
| 40 | ); |
||
| 41 | } else { |
||
| 42 | $this->decoratedLogger->getIO()->writeln( |
||
| 43 | $output, |
||
| 44 | $verbosity, |
||
| 45 | ); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | private static function getVerbosity(string $level): int |
||
| 50 | { |
||
| 51 | return match ($level) { |
||
| 52 | LogLevel::INFO => OutputInterface::VERBOSITY_VERBOSE, |
||
| 53 | LogLevel::DEBUG => OutputInterface::VERBOSITY_VERY_VERBOSE, |
||
| 54 | default => OutputInterface::OUTPUT_NORMAL, |
||
| 55 | }; |
||
| 56 | } |
||
| 57 | |||
| 58 | private static function getOutput(array $context): ?string |
||
| 59 | { |
||
| 60 | $knownKeys = ['stdout', 'stderr']; |
||
| 61 | |||
| 62 | foreach ($knownKeys as $knownKey) { |
||
| 63 | if (array_key_exists($knownKey, $context)) { |
||
| 64 | return $context[$knownKey]; |
||
| 65 | } |
||
| 66 | } |
||
| 67 | |||
| 68 | return null; |
||
| 69 | } |
||
| 70 | } |
||
| 71 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths