Fix Object parsing for Logging
authorPhilipp <admin@philipp.info>
Thu, 1 Apr 2021 18:55:25 +0000 (20:55 +0200)
committerPhilipp <admin@philipp.info>
Thu, 1 Apr 2021 18:55:25 +0000 (20:55 +0200)
src/Util/Logger/AbstractLogger.php
tests/src/Util/Logger/AbstractLoggerTest.php

index bbd50d6..a8aba34 100644 (file)
@@ -115,7 +115,7 @@ abstract class AbstractLogger implements LoggerInterface
                $output = [];
 
                foreach ($input as $key => $value) {
-                       if (method_exists($value, '__toString')) {
+                       if (is_object($value) && method_exists($value, '__toString')) {
                                $output[$key] = $value->__toString();
                        } else {
                                $output[$key] = $value;
index 3962333..5c87d1c 100644 (file)
@@ -178,4 +178,15 @@ abstract class AbstractLoggerTest extends MockedTest
 
                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());
+       }
 }