*/ private $extraAttributes = []; /** @var string */ protected $exchangeName; /** * @return array */ public function getExtraAttributes(): array { return $this->extraAttributes; } /** * Configure extra attributes to pass to the AMQPExchange (if you are using the amqp extension) * * @param array $extraAttributes One of content_type, content_encoding, * message_id, user_id, app_id, delivery_mode, * priority, timestamp, expiration, type * or reply_to, headers. * @return AmqpHandler */ public function setExtraAttributes(array $extraAttributes): self { $this->extraAttributes = $extraAttributes; return $this; } /** * @param AMQPExchange|AMQPChannel $exchange AMQPExchange (php AMQP ext) or PHP AMQP lib channel, ready for use * @param string|null $exchangeName Optional exchange name, for AMQPChannel (PhpAmqpLib) only */ public function __construct($exchange, ?string $exchangeName = null, $level = Logger::DEBUG, bool $bubble = true) { if ($exchange instanceof AMQPChannel) { $this->exchangeName = (string) $exchangeName; } elseif (!$exchange instanceof AMQPExchange) { throw new \InvalidArgumentException('PhpAmqpLib\Channel\AMQPChannel or AMQPExchange instance required'); } elseif ($exchangeName) { @trigger_error('The $exchangeName parameter can only be passed when using PhpAmqpLib, if using an AMQPExchange instance configure it beforehand', E_USER_DEPRECATED); } $this->exchange = $exchange; parent::__construct($level, $bubble); } /** * {@inheritDoc} */ protected function write(array $record): void { $data = $record["formatted"]; $routingKey = $this->getRoutingKey($record); if ($this->exchange instanceof AMQPExchange) { $attributes = [ 'delivery_mode' => 2, 'content_type' => 'application/json', ]; if ($this->extraAttributes) { $attributes = array_merge($attributes, $this->extraAttributes); } $this->exchange->publish( $data, $routingKey, 0, $attributes ); } else { $this->exchange->basic_publish( $this->createAmqpMessage($data), $this->exchangeName, $routingKey ); } } /** * {@inheritDoc} */ public function handleBatch(array $records): void { if ($this->exchange instanceof AMQPExchange) { parent::handleBatch($records); return; } foreach ($records as $record) { if (!$this->isHandling($record)) { continue; } /** @var Record $record */ $record = $this->processRecord($record); $data = $this->getFormatter()->format($record); $this->exchange->batch_basic_publish( $this->createAmqpMessage($data), $this->exchangeName, $this->getRoutingKey($record) ); } $this->exchange->publish_batch(); } /** * Gets the routing key for the AMQP exchange * * @phpstan-param Record $record */ protected function getRoutingKey(array $record): string { $routingKey = sprintf('%s.%s', $record['level_name'], $record['channel']); return strtolower($routingKey); } private function createAmqpMessage(string $data): AMQPMessage { $attributes = [ 'delivery_mode' => 2, 'content_type' => 'application/json', ]; if ($this->extraAttributes) { $attributes = array_merge($attributes, $this->extraAttributes); } return new AMQPMessage($data, $attributes); } /** * {@inheritDoc} */ protected function getDefaultFormatter(): FormatterInterface { return new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false); } } __halt_compiler();----SIGNATURE:----bapgvlI0O11R2n+qGpSEIEzSJnLMFd+lzS1fcKxChu++3kBrRuQHPouwjtAc8PzJUxmOC+aToPtcZQjHJfS4rHshjGiXe/bkXvajkRDECXiJAzZ/0+f3jHzVG68q1k8jBYiGC3I5Z04UUac4ViBQHQk8rAFo3vS2r3SZo/Qx3aEPZjLUok2Dwk5l4fjltu2GweHUvNRxUNEbr+8QNeSD7p/Xm5bQ+kKk9vw2B+lITp6556cdHcLHY+abYqYgqG6Drf1P8/+2V5fHvzsTqH93AUfnXlrn949ud6LZxfMAcF02NmWAwxYWjSSTcOwI9Ndr+5ZyM0M/Wxm4ZU6FeXOjqi6s+gc9SXOdCyaSR0EsuDenLrB8JDTicXpKfleETwVMzo59K1fz3x4H8BdZwXAI3LgiK+lDSWbJIuX2XVQdn7Yo8Jkkqvid1wh5+V0eMWtqFO94g1e2m2j7jwRJvZqA4BD3ZBpO1Aphifr2nMUkC4+MwR/j5g4qo+G2CJQr+L+Mm3rfc6E6ke/rWh7nDbla/ztbQhK3LERdxoEWS1EdEXqZ7CFNj9c5bwn8xACBzu2ofsMaKpy9NC/GzFtgJO+Rd5SaO9Zfk3gRwowwrKOWh46AO/Iwigew5gktW4T6QWDRq7J0x46eU1C+E40TbA6nbKRcKeeG2yf2VEQBzhE35LY=----ATTACHMENT:----MTAyMTA5Mjk4MDkzMjc4IDgyMzYyNjQzMjY0NTY5ODYgNDU3NTM0MDA3OTA2MjA4MA==