socket = new NotificationSocket($socket ?: self::JOURNALD_SOCKET); } /** * @param string|null $identifier * @return $this */ public function setIdentifier($identifier) { return $this->setExtraField('SYSLOG_IDENTIFIER', $identifier); } /** * @param string $name * @param ?string $value * @return $this */ public function setExtraField($name, $value) { if ($value === null) { unset($this->extraFields[$name]); } else { $this->extraFields[$name] = (string) $value; } return $this; } public function write($level, $message, $context = []) { $this->socket->send([ 'MESSAGE' => $message, 'PRIORITY' => LogLevel::mapNameToNumeric($level), ] + $context + $this->extraFields); } }