<?php

namespace App\Formatter;

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'],
            'datetime' => $record['datetime']->format('Y-m-d H:i:s'),
        ];

        return json_encode($output, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
    }
}