'elastic_index_name', * 'type' => 'elastic_doc_type', Types have been removed in Elastica 7 * ); * $handler = new ElasticaHandler($client, $options); * $log = new Logger('application'); * $log->pushHandler($handler); * * @author Jelle Vink */ class ElasticaHandler extends AbstractProcessingHandler { /** @var Client */ protected $client; /** @var mixed[] Handler config options */ protected $options = []; /** * @param Client $client Elastica Client object * @param mixed[] $options Handler configuration */ public function __construct(Client $client, array $options = [], $level = Logger::DEBUG, bool $bubble = true) { parent::__construct($level, $bubble); $this->client = $client; $this->options = array_merge( [ 'index' => 'monolog', // Elastic index name "type" => 'record', // Elastic document type "ignore_error" => false, // Suppress Elastica exceptions ], $options ); } /** * {@inheritDoc} */ protected function write(array $record): void { $this->bulkSend([$record['formatted']]); } /** * {@inheritDoc} */ public function setFormatter(FormatterInterface $formatter): HandlerInterface { if ($formatter instanceof ElasticaFormatter) { return parent::setFormatter($formatter); } throw new \InvalidArgumentException('ElasticaHandler is only compatible with ElasticaFormatter'); } /** * @return mixed[] */ public function getOptions(): array { return $this->options; } /** * {@inheritDoc} */ protected function getDefaultFormatter(): FormatterInterface { return new ElasticaFormatter($this->options['index'], $this->options['type']); } /** * {@inheritDoc} */ public function handleBatch(array $records): void { $documents = $this->getFormatter()->formatBatch($records); $this->bulkSend($documents); } /** * Use Elasticsearch bulk API to send list of documents * * @param Document[] $documents * * @throws \RuntimeException */ protected function bulkSend(array $documents): void { try { $this->client->addDocuments($documents); } catch (ExceptionInterface $e) { if (!$this->options['ignore_error']) { throw new \RuntimeException("Error sending messages to Elasticsearch", 0, $e); } } } } __halt_compiler();----SIGNATURE:----krVQIeCbL7xJGGFNJ9W/Fpp+kjBYuOb5eMENwrQU1zQ30pUNheejCHqwmMfy8KWV+8gUhfp9RTxamoDqiP1OvSKKNDqWoSMzwRXdmlimh6oyOgcueT6N12O5o0O/ggd4UFq5VEASRxvrCX8G/YMlnMIrvUhJJG8HIRtDlzTsgg+84NFLh2SepoUVyMobmfCzO+d/AU9cb5dl4zgfDN+LHmI/vZ4mXcioZeE/zXWN1fGG9SREsFw1dXKjJtqRgNcqBT3HF4j1mmiPyHv/qBLZR2q5Ogty4vMcJO7glP6ekUJAtntw1bTyY5H+vBTPANjqhSbCd7lsjL9mhA1z5j4sLqto+QVEv6lbDjUx158EiFk19/N44OkBTeZQZ6/jIdm7e6L2RsAewYhUoUlnDUfvImIKiBSOTK/KZWk33WrrtJeFiQ37nwBekBOq94c41b4LsGn5mPWH7pl0V8tf+qcmcWe7XXepbJBYVy+CR3XvJMs5gVvOxACYz6VxDBof9TYvyocZYZsP1IdS4xlwmB35uiZbS5+l5UUTjoejSbEO5HQCAQWOwOIFOsX4M0FQ6pLQrSIr31ir+GK+U/J3KeQvAXsYi9RH+HxfjpgzZTWB6viA7Cb1XnE1UrvyTkPa+jxiPHko9U2q/HsYtG2Iy1FR612mTl4iyGWE8PeQt+Fvzk8=----ATTACHMENT:----ODMxNjU2ODI1OTExNzEzIDc3NTQ4NjQ2MTM2MTYwNjEgMzYxMjY2NzY5ODkwMDQx