diff --git a/Console/Command/WarmNodeCommand.php b/Console/Command/WarmNodeCommand.php index a38b0c9..6c1a7c2 100644 --- a/Console/Command/WarmNodeCommand.php +++ b/Console/Command/WarmNodeCommand.php @@ -49,8 +49,7 @@ private function setAreaCode() protected function execute( \Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output - ) - { + ): int { $this->setAreaCode(); $force = $input->getOption('force'); @@ -65,6 +64,10 @@ protected function execute( $output->writeln($message); file_put_contents($this->nodeWarmer->getWarmupLogFilePath(), $message); + + return \Magento\Framework\Console\Cli::RETURN_FAILURE; } + + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } diff --git a/Log/CapturingLoggerDecorator.php b/Log/CapturingLoggerDecorator.php index 077dd96..826bbe5 100644 --- a/Log/CapturingLoggerDecorator.php +++ b/Log/CapturingLoggerDecorator.php @@ -38,9 +38,9 @@ public function flush() * @param string $message * @param array $context */ - public function log($level, $message, array $context = array()) + public function log($level, string|\Stringable $message, array $context = []): void { $this->upstreamLogger->log($level, $message, $context); $this->buffer[] = [time(), $level, $message]; } -} \ No newline at end of file +} diff --git a/Log/LogFormatter.php b/Log/LogFormatter.php index a2becbc..06aea0f 100644 --- a/Log/LogFormatter.php +++ b/Log/LogFormatter.php @@ -4,12 +4,21 @@ class LogFormatter implements \Monolog\Formatter\FormatterInterface { - public function format(array $record) + public function format(array|\Monolog\LogRecord $record) { + if (is_array($record)) { + [$timestamp, $level, $message] = $record; + return sprintf('[%s] [%s] %s', + date('Y-m-d H:i:s', $timestamp), + $level, + $message + ); + } + return sprintf('[%s] [%s] %s', - date('Y-m-d H:i:s', $record[0]), - $record[1], - $record[2] + date('Y-m-d H:i:s', $record->datetime->getTimestamp()), + $record->level->getName(), + $record->message ); } @@ -17,4 +26,4 @@ public function formatBatch(array $records) { return implode("\n", array_map([$this, 'format'], $records)); } -} \ No newline at end of file +}