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

Fix utf8_encode deprecation (#1722)

This commit is contained in:
erikn69
2022-07-22 07:23:53 -05:00
committed by GitHub
parent 83db4b3f81
commit 27dc1b2ef7
3 changed files with 10 additions and 10 deletions

View File

@@ -149,7 +149,7 @@ class ChromePHPHandler extends AbstractProcessingHandler
} }
$json = Utils::jsonEncode(self::$json, Utils::DEFAULT_JSON_FLAGS & ~JSON_UNESCAPED_UNICODE, true); $json = Utils::jsonEncode(self::$json, Utils::DEFAULT_JSON_FLAGS & ~JSON_UNESCAPED_UNICODE, true);
$data = base64_encode(utf8_encode($json)); $data = base64_encode($json);
if (strlen($data) > 3 * 1024) { if (strlen($data) > 3 * 1024) {
self::$overflowed = true; self::$overflowed = true;
@@ -163,8 +163,8 @@ class ChromePHPHandler extends AbstractProcessingHandler
'extra' => [], 'extra' => [],
]; ];
self::$json['rows'][count(self::$json['rows']) - 1] = $this->getFormatter()->format($record); self::$json['rows'][count(self::$json['rows']) - 1] = $this->getFormatter()->format($record);
$json = Utils::jsonEncode(self::$json, null, true); $json = Utils::jsonEncode(self::$json, Utils::DEFAULT_JSON_FLAGS & ~JSON_UNESCAPED_UNICODE, true);
$data = base64_encode(utf8_encode($json)); $data = base64_encode($json);
} }
if (trim($data) !== '') { if (trim($data) !== '') {

View File

@@ -211,7 +211,7 @@ final class Utils
$data = preg_replace_callback( $data = preg_replace_callback(
'/[\x80-\xFF]+/', '/[\x80-\xFF]+/',
function ($m) { function ($m) {
return utf8_encode($m[0]); return function_exists('mb_convert_encoding') ? mb_convert_encoding($m[0], 'UTF-8', 'ISO-8859-1') : utf8_encode($m[0]);
}, },
$data $data
); );

View File

@@ -38,7 +38,7 @@ class ChromePHPHandlerTest extends TestCase
$handler->handle($this->getRecord(Logger::WARNING)); $handler->handle($this->getRecord(Logger::WARNING));
$expected = [ $expected = [
'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode([ 'X-ChromeLogger-Data' => base64_encode(json_encode([
'version' => '4.0', 'version' => '4.0',
'columns' => ['label', 'log', 'backtrace', 'type'], 'columns' => ['label', 'log', 'backtrace', 'type'],
'rows' => [ 'rows' => [
@@ -46,7 +46,7 @@ class ChromePHPHandlerTest extends TestCase
'test', 'test',
], ],
'request_uri' => '', 'request_uri' => '',
]))), ])),
]; ];
$this->assertEquals($expected, $handler->getHeaders()); $this->assertEquals($expected, $handler->getHeaders());
@@ -72,7 +72,7 @@ class ChromePHPHandlerTest extends TestCase
$handler->handle($this->getRecord(Logger::WARNING, str_repeat('b', 2 * 1024))); $handler->handle($this->getRecord(Logger::WARNING, str_repeat('b', 2 * 1024)));
$expected = [ $expected = [
'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode([ 'X-ChromeLogger-Data' => base64_encode(json_encode([
'version' => '4.0', 'version' => '4.0',
'columns' => ['label', 'log', 'backtrace', 'type'], 'columns' => ['label', 'log', 'backtrace', 'type'],
'rows' => [ 'rows' => [
@@ -96,7 +96,7 @@ class ChromePHPHandlerTest extends TestCase
], ],
], ],
'request_uri' => '', 'request_uri' => '',
]))), ])),
]; ];
$this->assertEquals($expected, $handler->getHeaders()); $this->assertEquals($expected, $handler->getHeaders());
@@ -115,7 +115,7 @@ class ChromePHPHandlerTest extends TestCase
$handler2->handle($this->getRecord(Logger::WARNING)); $handler2->handle($this->getRecord(Logger::WARNING));
$expected = [ $expected = [
'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode([ 'X-ChromeLogger-Data' => base64_encode(json_encode([
'version' => '4.0', 'version' => '4.0',
'columns' => ['label', 'log', 'backtrace', 'type'], 'columns' => ['label', 'log', 'backtrace', 'type'],
'rows' => [ 'rows' => [
@@ -125,7 +125,7 @@ class ChromePHPHandlerTest extends TestCase
'test', 'test',
], ],
'request_uri' => '', 'request_uri' => '',
]))), ])),
]; ];
$this->assertEquals($expected, $handler2->getHeaders()); $this->assertEquals($expected, $handler2->getHeaders());