*/ 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:----FAKUlbz3GSts640GJZHIfYuQNS89dnLZ6S9aHdY3TaOdLmVJOqWioW2SNzDh7/FRgSM3wC59Tn7i+QJOzrQqQZI2o1gjKHbSe8D3FShEje9h7/FnseNsf7ec2VBMPUROt1xy+4o4WTomqz/uWnE8uJAWEeF01VpWywSOTlpdT0qUKJVRxwItMUb3W4+DO4a5gh2njuaq5CjKCpYqL3PSwZuM4h+hqC1Vutr5kz4IctXK8V4iSMEX5DFIb3QRCdVvhpeir9biBefpkcNolcZ04gTAcgvwt6g1kVz1JKW+ZU0qgkCbE88WTHj/N7HCwJSjrqslBOK0CkvVPA8VAOzViXzJ+UDukCclkBKPQ8iad4se4Rra6dPQLuGvPIh9AoWwIC+8opk5nErv8SlM/ungLnZSEOuK8A0raaqw539eHNVpXJkCuaUR92t4iC/CbDJwC7YAlgDl2VbxrqVMpW72R+brEJqAms4oVooGYgCYYOs7+nQKB0ihhsxSSyOubqI31lkfdT7x+rklBCug6hM8vFVyDgy+/2zjEaMjtVE2A5BGGNDuOKyfEztBVGBhVi7DUsr3QP/zO7jZEBgEpQT4M0b2ilalJs3dT5j5KFKfIlOqAYOP1I9/TeNM8ckb2oP4u22d+a1sU4lyUPMobTPK87WDliumB3scklubceKtoeM=----ATTACHMENT:----NTAyNDQ5NTY4MzY2MjIzMCA3ODc1MzQyODIwNzEzNzQxIDc4Njc5NzUwNzQ1NzgzMDI=