Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 107428f

Browse files
Fix support for monolog 3.0
1 parent d87cd8d commit 107428f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Symfony/Bridge/Monolog/Command/ServerLogCommand.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414
use Monolog\Formatter\FormatterInterface;
1515
use Monolog\Handler\HandlerInterface;
16+
use Monolog\Level;
1617
use Monolog\Logger;
18+
use Monolog\LogRecord;
1719
use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter;
1820
use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
1921
use Symfony\Component\Console\Attribute\AsCommand;
@@ -119,6 +121,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
119121
continue;
120122
}
121123

124+
if (Logger::API >= 3) {
125+
$record = new LogRecord(
126+
level: Level::fromValue($record['level']),
127+
channel: $record['channel'],
128+
context: $record['context']->getContext(),
129+
datetime: $record['datetime'],
130+
message: $record['message'],
131+
);
132+
}
133+
122134
$this->displayLog($output, $clientId, $record);
123135
}
124136

@@ -148,7 +160,7 @@ private function getLogs($socket): iterable
148160
}
149161
}
150162

151-
private function displayLog(OutputInterface $output, int $clientId, array $record): void
163+
private function displayLog(OutputInterface $output, int $clientId, array|LogRecord $record): void
152164
{
153165
if (isset($record['log_id'])) {
154166
$clientId = unpack('H*', $record['log_id'])[1];

0 commit comments

Comments
 (0)