diff --git a/ConsoleTarget.php b/ConsoleTarget.php index f6bb27e..2fe0f69 100644 --- a/ConsoleTarget.php +++ b/ConsoleTarget.php @@ -122,10 +122,13 @@ private function generateLabel($message) private function generateText($message) { $text = $message[0]; - if (is_array($text) || is_object($text)) { - $text = "Array content is \n\r".json_encode($text, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); - } elseif (!is_string($text)) { - $text = 'Message is ' . gettype($text); + if (!is_string($text)) { + // exceptions may not be serializable if in the call stack somewhere is a Closure + if ($text instanceof \Throwable || $text instanceof \Exception) { + $text = (string) $text; + } else { + $text = VarDumper::export($text); + } } return $text; }