Skip to content

Compatibility with Magento 2.4.8-beta2 Upgrade monolog package #926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 2.4-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion src/Migration/Logger/ConsoleHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/Migration/Logger/FileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
11 changes: 7 additions & 4 deletions src/Migration/Logger/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

namespace Migration\Logger;

use Monolog\DateTimeImmutable;
use Monolog\JsonSerializableDateTimeImmutable;
use Monolog\Level;

/**
* Processing logger handler creation for migration application
Expand All @@ -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;
}

Expand Down
6 changes: 4 additions & 2 deletions src/Migration/Logger/MessageFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
namespace Migration\Logger;

use Monolog\LogRecord;

/**
* Format logger messages corresponding to verbosity level
*/
Expand All @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/Migration/Logger/MessageProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
namespace Migration\Logger;

use Monolog\LogRecord;

/**
* Logger messages processor
*/
Expand All @@ -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) {
Expand Down