18use Elastica\Exception\ExceptionInterface;
58 $this->options = array_merge(
62 'ignore_error' =>
false,
71 protected function write(array $record)
73 $this->
bulkSend(array($record[
'formatted']));
84 throw new \InvalidArgumentException(
'ElasticSearchHandler is only compatible with ElasticaFormatter');
109 $documents = $this->
getFormatter()->formatBatch($records);
121 $this->client->addDocuments($documents);
122 }
catch (ExceptionInterface $e) {
123 if (!$this->options[
'ignore_error']) {
124 throw new \RuntimeException(
"Error sending messages to Elasticsearch", 0, $e);
getFormatter()
{Gets the formatter.FormatterInterface}
Base Handler class providing the Handler structure.
getOptions()
Getter options.
__construct(Client $client, array $options=array(), $level=Logger::DEBUG, $bubble=true)
write(array $record)
Writes the record down to the log of the implementing handler.void
setFormatter(FormatterInterface $formatter)
{{Sets the formatter.self}}
handleBatch(array $records)
{{Handles a set of records at once.}}
getDefaultFormatter()
Gets the default formatter.FormatterInterface
bulkSend(array $documents)
Use Elasticsearch bulk API to send list of documents.
const DEBUG
Detailed debug information.