1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-03 19:57:41 +02:00

set json flags correctly for SlackRecord, fixes #1396, closes #1397

This commit is contained in:
Jordi Boggiano
2019-11-13 10:47:25 +01:00
parent f97cc755af
commit ec3e0e3f90

View File

@@ -208,13 +208,17 @@ class SlackRecord
{
$normalized = $this->normalizerFormatter->format($fields);
$prettyPrintFlag = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 128;
$flags = 0;
if (PHP_VERSION_ID >= 50400) {
$flags = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
}
$hasSecondDimension = count(array_filter($normalized, 'is_array'));
$hasNonNumericKeys = !count(array_filter(array_keys($normalized), 'is_numeric'));
return $hasSecondDimension || $hasNonNumericKeys
? Utils::jsonEncode($normalized, $prettyPrintFlag)
: Utils::jsonEncode($normalized);
? Utils::jsonEncode($normalized, $prettyPrintFlag | $flags)
: Utils::jsonEncode($normalized, $flags);
}
/**