Created
October 26, 2022 09:21
-
-
Save pavarov/b96f5eaad0172345e3ae0b221f258f5e to your computer and use it in GitHub Desktop.
Extended json fromatter for monolog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Settings\Logger; | |
use Monolog\Formatter\JsonFormatter; | |
use Monolog\LogRecord; | |
class JsonPrettyUnicodePrintFormatter extends JsonFormatter | |
{ | |
/** | |
* {@inheritdoc} | |
*/ | |
public function format(LogRecord $record): string | |
{ | |
return | |
json_encode( | |
$record, | |
JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | |
) . ($this->appendNewline ? "\n" : ''); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment