Skip to content

Commit 68b6c3b

Browse files
ttskchnicolas-grekas
authored andcommitted
[Console] ensure SHELL_VERBOSITY is always restored properly
1 parent 58a6bb0 commit 68b6c3b

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

Log/Logger.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,13 @@ class Logger extends AbstractLogger implements DebugLoggerInterface
5959
*/
6060
public function __construct(?string $minLevel = null, $output = null, ?callable $formatter = null, private readonly ?RequestStack $requestStack = null, bool $debug = false)
6161
{
62-
if (null === $minLevel) {
63-
$minLevel = null === $output || 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::ERROR : LogLevel::WARNING;
64-
65-
if (isset($_ENV['SHELL_VERBOSITY']) || isset($_SERVER['SHELL_VERBOSITY'])) {
66-
$minLevel = match ((int) ($_ENV['SHELL_VERBOSITY'] ?? $_SERVER['SHELL_VERBOSITY'])) {
67-
-1 => LogLevel::ERROR,
68-
1 => LogLevel::NOTICE,
69-
2 => LogLevel::INFO,
70-
3 => LogLevel::DEBUG,
71-
default => $minLevel,
72-
};
73-
}
74-
}
62+
$minLevel ??= match ((int) ($_ENV['SHELL_VERBOSITY'] ?? $_SERVER['SHELL_VERBOSITY'] ?? 0)) {
63+
-1 => LogLevel::ERROR,
64+
1 => LogLevel::NOTICE,
65+
2 => LogLevel::INFO,
66+
3 => LogLevel::DEBUG,
67+
default => null === $output || 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::ERROR : LogLevel::WARNING,
68+
};
7569

7670
if (!isset(self::LEVELS[$minLevel])) {
7771
throw new InvalidArgumentException(\sprintf('The log level "%s" does not exist.', $minLevel));

0 commit comments

Comments
 (0)