Skip to content

Instantly share code, notes, and snippets.

@pavarov
Created October 26, 2022 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavarov/b96f5eaad0172345e3ae0b221f258f5e to your computer and use it in GitHub Desktop.
Save pavarov/b96f5eaad0172345e3ae0b221f258f5e to your computer and use it in GitHub Desktop.
Extended json fromatter for monolog
<?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