*/ class LogstashFormatter extends NormalizerFormatter { /** @var string the name of the system for the Logstash log message, used to fill the @source field */ protected $systemName; /** @var string an application name for the Logstash log message, used to fill the @type field */ protected $applicationName; /** @var string the key for 'extra' fields from the Monolog record */ protected $extraKey; /** @var string the key for 'context' fields from the Monolog record */ protected $contextKey; /** * @param string $applicationName The application that sends the data, used as the "type" field of logstash * @param string|null $systemName The system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine * @param string $extraKey The key for extra keys inside logstash "fields", defaults to extra * @param string $contextKey The key for context keys inside logstash "fields", defaults to context */ public function __construct( string $applicationName, ?string $systemName = null, string $extraKey = 'extra', string $contextKey = 'context', ) { // logstash requires a ISO 8601 format date with optional millisecond precision. parent::__construct('Y-m-d\TH:i:s.uP'); $this->systemName = $systemName === null ? (string) gethostname() : $systemName; $this->applicationName = $applicationName; $this->extraKey = $extraKey; $this->contextKey = $contextKey; } /** * {@inheritDoc} */ public function format(array $record): string { $record = parent::format($record); if (empty($record['datetime'])) { $record['datetime'] = gmdate('c'); } $message = [ '@timestamp' => $record['datetime'], '@version' => 1, 'host' => $this->systemName, ]; if (isset($record['message'])) { $message['message'] = $record['message']; } if (isset($record['channel'])) { $message['type'] = $record['channel']; $message['channel'] = $record['channel']; } if (isset($record['level_name'])) { $message['level'] = $record['level_name']; } if (isset($record['level'])) { $message['monolog_level'] = $record['level']; } if ($this->applicationName) { $message['type'] = $this->applicationName; } if (!empty($record['extra'])) { $message[$this->extraKey] = $record['extra']; } if (!empty($record['context'])) { $message[$this->contextKey] = $record['context']; } return $this->toJson($message) . "\n"; } } __halt_compiler();----SIGNATURE:----relRmnWaSWOonx9pLURVhq8TnB+FKLeaBuJtc5ovOKWgc/K76jW1QhQkGzy+xM3zaLd+NqBpg/VyvRcizhwNIXM/I4gLroz6t/xbTryHSdS+2Z+yIvmJNwTkKkl7pmLKNAmMO3BKByERXAf1mo61YS3hNtAhWnr98jUf/vc46gCNaGpGmu5PJCuyv2QyaUKpGmbQe9lI8FC0vk16sQUQeCqkC4dyrt7Z8JlK3r3B/2H1zbH8pCLdX0uHzN1oTZVMghCRYzbXJOqw+poaFadhzi8//cSKig9SxxncshpJl53uzjefIXiRE6SQu7updvtB9mn7MEEM9I6L/3pe9orlV5daNy814Id37J72m9xUEzAn5ZgVUM17uz8+QulXMcsJHRv2GYpavLtxnC4Aeqg3ogmmOM+h8mrDUYhkYzQoIzbyLeBKhivPxdnV4Nv2d/9g4pPlSgSM+NklMWRV0sS7LzYlMzI1etbSet1nklJBYiWMs8135nzNc9v3GpitCfGLJrJCfWBXEyB8qc8qBbaLvqZGkYzgi57+pOcgqlOlH3Ekd88Rw7OZq1Ew8fNggaO+CeBqiJad5ZbZJ2rbJe+qODvEVHa84Bd/8xokmV4FrAI8An5NYZyzX+Trqs3IzpoDH6L2ZVMM1U1+UDIlwd4bw6s7kgm+dmpy7ozcJYG2/SE=----ATTACHMENT:----NjI2OTkyNzc1NTA3OTc2MyA0MjcyMDY5NDc4NTQzMzU0IDY3NTc1MjQ2NzQxNDU5MDk=