Skip to content

Commit e60e655

Browse files
committed
ACP2E-1287: log exception to exception.log for all levels to preserve backward compatibility
1 parent c85e8a8 commit e60e655

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/internal/Magento/Framework/Logger/LoggerProxy.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ public function critical($message, array $context = [])
126126
*/
127127
public function error($message, array $context = [])
128128
{
129+
$context = $this->addExceptionToContext($message, $context);
129130
$this->getLogger()->error($message, $context);
130131
}
131132

@@ -134,6 +135,7 @@ public function error($message, array $context = [])
134135
*/
135136
public function warning($message, array $context = [])
136137
{
138+
$context = $this->addExceptionToContext($message, $context);
137139
$this->getLogger()->warning($message, $context);
138140
}
139141

@@ -142,6 +144,7 @@ public function warning($message, array $context = [])
142144
*/
143145
public function notice($message, array $context = [])
144146
{
147+
$context = $this->addExceptionToContext($message, $context);
145148
$this->getLogger()->notice($message, $context);
146149
}
147150

@@ -150,6 +153,7 @@ public function notice($message, array $context = [])
150153
*/
151154
public function info($message, array $context = [])
152155
{
156+
$context = $this->addExceptionToContext($message, $context);
153157
$this->getLogger()->info($message, $context);
154158
}
155159

@@ -158,6 +162,7 @@ public function info($message, array $context = [])
158162
*/
159163
public function debug($message, array $context = [])
160164
{
165+
$context = $this->addExceptionToContext($message, $context);
161166
$this->getLogger()->debug($message, $context);
162167
}
163168

@@ -166,6 +171,7 @@ public function debug($message, array $context = [])
166171
*/
167172
public function log($level, $message, array $context = [])
168173
{
174+
$context = $this->addExceptionToContext($message, $context);
169175
$this->getLogger()->log($level, $message, $context);
170176
}
171177

lib/internal/Magento/Framework/Logger/Test/Unit/LoggerProxyTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,8 @@ public function logException($method): void
124124
->withConsecutive([DeploymentConfig::class], [Monolog::class])
125125
->willReturnOnConsecutiveCalls($deploymentConfig, $logger);
126126

127-
if (in_array($method, ['critical', 'emergency', 'alert'])) {
128-
$message = new \Exception('This is an exception.');
129-
} else {
130-
$message = 'test';
131-
}
127+
$message = new \Exception('This is an exception.');
128+
132129
$logger->expects($this->once())->method($method)->with($message);
133130

134131
$loggerProxy = new LoggerProxy($objectManager);

0 commit comments

Comments
 (0)