refs #1324. CustomLineFormatter
testing/ogcore-api/pipeline/head There was a failure building this commit Details

pull/18/head
Manuel Aranda Rosales 2025-01-09 08:13:06 +01:00
parent 166c629906
commit 4efa843445
1 changed files with 20 additions and 2 deletions

View File

@ -2,7 +2,25 @@
namespace App\Formatter;
class CustomLineFormatter
{
use Monolog\Formatter\LineFormatter;
class CustomLineFormatter extends LineFormatter
{
public function __construct()
{
parent::__construct(null, 'Y-m-d H:i:s', true, true);
}
public function format($record): string
{
$output = [
'severity' => $record['level_name'],
'operation' => $record['channel'],
'component' => 'ogcore',
'params' => $record['context'],
'desc' => $record['message'],
];
return json_encode($output, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . PHP_EOL;
}
}