Skip to content

Commit 10eed96

Browse files
committed
ICL: convertToString method overridden.
1 parent b5bf0a3 commit 10eed96

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/Log/Formatter.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,36 @@ public function format(array $record)
1616
$output = parent::format($record);
1717
return rtrim($output) . "\n";
1818
}
19+
20+
protected function convertToString($data)
21+
{
22+
$decoded = is_json($data, true);
23+
if ($decoded) {
24+
$data = $decoded;
25+
}
26+
27+
if (is_string($data)) {
28+
return $data;
29+
}
30+
31+
return var_export($data, true);
32+
}
33+
}
34+
35+
36+
37+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
38+
function is_json($string, $return = false)
39+
{
40+
if (!is_string($string)) {
41+
return false;
42+
}
43+
44+
$data = json_decode($string);
45+
if (json_last_error() != JSON_ERROR_NONE) {
46+
return false;
47+
}
48+
49+
return ($return ? $data : true);
1950
}
51+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)