Skip to content

Commit 3d9422b

Browse files
committed
AC-12022::Upgrade monolog/monolog system dependency to the latest major version
1 parent 2dfe102 commit 3d9422b

File tree

5 files changed

+27
-16
lines changed

5 files changed

+27
-16
lines changed

app/code/Magento/Developer/Model/Logger/Handler/Debug.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Framework\Exception\RuntimeException;
1616
use Magento\Framework\Filesystem\DriverInterface;
1717
use Magento\Framework\Logger\Handler\Debug as DebugHandler;
18+
use Monolog\LogRecord;
1819

1920
/**
2021
* Enable/disable debug logging based on the store config setting
@@ -53,7 +54,7 @@ public function __construct(
5354
/**
5455
* @inheritdoc
5556
*/
56-
public function isHandling(array $record): bool
57+
public function isHandling(LogRecord $record): bool
5758
{
5859
if ($this->deploymentConfig->isAvailable()) {
5960
return parent::isHandling($record) && $this->isLoggingEnabled();

app/code/Magento/Developer/Model/Logger/Handler/Syslog.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Config\Setup\ConfigOptionsList;
1111
use Magento\Framework\App\Config\ScopeConfigInterface;
1212
use Magento\Framework\App\DeploymentConfig;
13+
use Monolog\LogRecord;
1314

1415
/**
1516
* Enable/disable syslog logging based on the deployment config setting.
@@ -43,7 +44,7 @@ public function __construct(
4344
/**
4445
* @inheritdoc
4546
*/
46-
public function isHandling(array $record): bool
47+
public function isHandling(LogRecord $record): bool
4748
{
4849
return parent::isHandling($record)
4950
&& $this->deploymentConfig->isDbAvailable()

app/code/Magento/Developer/Test/Unit/Model/Logger/Handler/SyslogTest.php

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\App\Config\ScopeConfigInterface;
1313
use Magento\Framework\App\DeploymentConfig;
1414
use Magento\Framework\Logger\Monolog;
15+
use Monolog\LogRecord;
1516
use PHPUnit\Framework\MockObject\MockObject as Mock;
1617
use PHPUnit\Framework\TestCase;
1718

@@ -35,13 +36,19 @@ class SyslogTest extends TestCase
3536
*/
3637
private $deploymentConfigMock;
3738

39+
/**
40+
* @var LogRecord|Mock
41+
*/
42+
private $logRecordMock;
43+
3844
/**
3945
* @inheritdoc
4046
*/
4147
protected function setUp(): void
4248
{
4349
$this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
4450
$this->deploymentConfigMock = $this->createMock(DeploymentConfig::class);
51+
$this->logRecordMock = $this->createMock(LogRecord::class);
4552

4653
$this->model = new Syslog(
4754
$this->deploymentConfigMock,
@@ -54,9 +61,9 @@ protected function setUp(): void
5461
*/
5562
public function testIsHandling(): void
5663
{
57-
$record = [
58-
'level' => Monolog::DEBUG,
59-
];
64+
// $record = [
65+
// 'level' => Monolog::DEBUG,
66+
// ];
6067

6168
$this->scopeConfigMock
6269
->expects($this->never())
@@ -72,7 +79,7 @@ public function testIsHandling(): void
7279
->willReturn(1);
7380

7481
$this->assertTrue(
75-
$this->model->isHandling($record)
82+
$this->model->isHandling($this->logRecordMock)
7683
);
7784
}
7885

@@ -81,9 +88,9 @@ public function testIsHandling(): void
8188
*/
8289
public function testIsHandlingNotInstalled(): void
8390
{
84-
$record = [
85-
'level' => Monolog::DEBUG,
86-
];
91+
// $record = [
92+
// 'level' => Monolog::DEBUG,
93+
// ];
8794

8895
$this->scopeConfigMock
8996
->expects($this->never())
@@ -94,7 +101,7 @@ public function testIsHandlingNotInstalled(): void
94101
->willReturn(false);
95102

96103
$this->assertFalse(
97-
$this->model->isHandling($record)
104+
$this->model->isHandling($this->logRecordMock)
98105
);
99106
}
100107

@@ -103,9 +110,9 @@ public function testIsHandlingNotInstalled(): void
103110
*/
104111
public function testIsHandlingDisabled(): void
105112
{
106-
$record = [
107-
'level' => Monolog::DEBUG,
108-
];
113+
// $record = [
114+
// 'level' => Monolog::DEBUG,
115+
// ];
109116

110117
$this->scopeConfigMock
111118
->expects($this->never())
@@ -121,7 +128,7 @@ public function testIsHandlingDisabled(): void
121128
->willReturn(0);
122129

123130
$this->assertFalse(
124-
$this->model->isHandling($record)
131+
$this->model->isHandling($this->logRecordMock)
125132
);
126133
}
127134
}

lib/internal/Magento/Framework/Logger/Handler/Base.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Monolog\Formatter\LineFormatter;
1414
use Monolog\Handler\StreamHandler;
1515
use Monolog\Logger;
16+
use Monolog\LogRecord;
1617

1718
/**
1819
* Base stream handler
@@ -87,7 +88,7 @@ private function sanitizeFileName(string $fileName): string
8788
/**
8889
* @inheritDoc
8990
*/
90-
protected function write(array $record): void
91+
protected function write(LogRecord $record): void
9192
{
9293
$logDir = $this->filesystem->getParentDirectory($this->url);
9394

lib/internal/Magento/Framework/Logger/Handler/System.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\Filesystem\DriverInterface;
1212
use Magento\Framework\Logger\Handler\Exception as ExceptionHandler;
1313
use Monolog\Logger;
14+
use Monolog\LogRecord;
1415

1516
/**
1617
* System stream handler
@@ -53,7 +54,7 @@ public function __construct(
5354
* @param array $record The record metadata
5455
* @return void
5556
*/
56-
public function write(array $record): void
57+
public function write(LogRecord $record): void
5758
{
5859
if (isset($record['context']['exception'])) {
5960
$this->exceptionHandler->handle($record);

0 commit comments

Comments
 (0)