Fix Object parsing for Logging

This commit is contained in:
Philipp 2021-04-01 20:55:25 +02:00
parent 8285a3a280
commit b983559980
No known key found for this signature in database
GPG Key ID: 9A28B7D4FF5667BD
2 changed files with 12 additions and 1 deletions

View File

@ -115,7 +115,7 @@ abstract class AbstractLogger implements LoggerInterface
$output = []; $output = [];
foreach ($input as $key => $value) { foreach ($input as $key => $value) {
if (method_exists($value, '__toString')) { if (is_object($value) && method_exists($value, '__toString')) {
$output[$key] = $value->__toString(); $output[$key] = $value->__toString();
} else { } else {
$output[$key] = $value; $output[$key] = $value;

View File

@ -178,4 +178,15 @@ abstract class AbstractLoggerTest extends MockedTest
self::assertContains(@json_encode($assertion), $this->getContent()); self::assertContains(@json_encode($assertion), $this->getContent());
} }
public function testNoObjectHandling()
{
$logger = $this->getInstance();
$logger->alert('test', ['e' => ['test' => 'test']]);
$text = $this->getContent();
self::assertLogline($text);
self::assertContains('test', $this->getContent());
}
} }