diff --git a/composer.json b/composer.json index 93fbf99b..56c01c44 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "require": { "symfony/console": "^6.4", "magento/framework": "*", - "monolog/monolog": "^2.3" + "monolog/monolog": "^3.6" }, "require-dev": { "phpunit/phpunit": "~9.5.0" diff --git a/src/Migration/Logger/ConsoleHandler.php b/src/Migration/Logger/ConsoleHandler.php index c59aeca1..7ad915c7 100644 --- a/src/Migration/Logger/ConsoleHandler.php +++ b/src/Migration/Logger/ConsoleHandler.php @@ -10,6 +10,7 @@ use Monolog\Handler\HandlerInterface; use Monolog\Handler\AbstractHandler; use Psr\Log\LogLevel; +use Monolog\LogRecord; /** * Processing logger handler creation for migration application @@ -46,7 +47,7 @@ protected function colorize($string, $color) /** * @inheritdoc */ - public function handle(array $record): bool + public function handle(LogRecord $record): bool { if (!$this->isHandling($record)) { return false; diff --git a/src/Migration/Logger/FileHandler.php b/src/Migration/Logger/FileHandler.php index 8af386e1..fb0f9663 100644 --- a/src/Migration/Logger/FileHandler.php +++ b/src/Migration/Logger/FileHandler.php @@ -10,6 +10,7 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Monolog\Formatter\FormatterInterface; use Monolog\Handler\HandlerInterface; +use Monolog\LogRecord; /** * Processing logger handler creation for migration application @@ -59,7 +60,7 @@ public function __construct(File $file, Config $config, \Magento\Framework\Files /** * @inheritdoc */ - public function handle(array $record): bool + public function handle(LogRecord $record): bool { if (!$this->isHandling($record)) { return false; diff --git a/src/Migration/Logger/Logger.php b/src/Migration/Logger/Logger.php index d933bb59..c5921e40 100644 --- a/src/Migration/Logger/Logger.php +++ b/src/Migration/Logger/Logger.php @@ -6,7 +6,8 @@ namespace Migration\Logger; -use Monolog\DateTimeImmutable; +use Monolog\JsonSerializableDateTimeImmutable; +use Monolog\Level; /** * Processing logger handler creation for migration application @@ -33,10 +34,12 @@ public function __construct($name = 'Migration', array $handlers = [], array $pr /** * @inheritdoc */ - public function addRecord(int $level, string $message, array $context = [], DateTimeImmutable $datetime = null): bool + + public function addRecord(int|Level $level, string $message, array $context = [], JsonSerializableDateTimeImmutable|null $datetime = null): bool { - $processed = parent::addRecord($level, $message, $context); - self::$messages[$level][] = $message; + $levelValue = $level instanceof Level ? $level->value : $level; + $processed = parent::addRecord($levelValue, $message, $context); + self::$messages[$levelValue][] = $message; return $processed; } diff --git a/src/Migration/Logger/MessageFormatter.php b/src/Migration/Logger/MessageFormatter.php index 51b734c7..c998c51e 100644 --- a/src/Migration/Logger/MessageFormatter.php +++ b/src/Migration/Logger/MessageFormatter.php @@ -5,6 +5,8 @@ */ namespace Migration\Logger; +use Monolog\LogRecord; + /** * Format logger messages corresponding to verbosity level */ @@ -13,12 +15,12 @@ class MessageFormatter extends \Monolog\Formatter\LineFormatter implements \Mono /** * @inheritdoc */ - protected $format; + protected string $format; /** * @inheritdoc */ - public function format(array $record): string + public function format(LogRecord $record): string { $this->format = $this->getLevelFormat($record['level_name']); return parent::format($record); diff --git a/src/Migration/Logger/MessageProcessor.php b/src/Migration/Logger/MessageProcessor.php index 7f66ce39..bfb91c73 100644 --- a/src/Migration/Logger/MessageProcessor.php +++ b/src/Migration/Logger/MessageProcessor.php @@ -5,6 +5,8 @@ */ namespace Migration\Logger; +use Monolog\LogRecord; + /** * Logger messages processor */ @@ -23,10 +25,10 @@ class MessageProcessor /** * Set extra * - * @param array $record + * @param LogRecord $record * @return array */ - public function setExtra(array $record) + public function setExtra(LogRecord $record) { foreach ($record['context'] as $key => $value) { switch ($key) {