From 80f7dc77d430774192b929d780f96260066df2ee Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 18 Oct 2015 09:31:31 +0200 Subject: Update to MediaWiki 1.25.3 --- .../src/Monolog/Handler/ElasticSearchHandler.php | 128 --------------------- 1 file changed, 128 deletions(-) delete mode 100644 vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php (limited to 'vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php') diff --git a/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php deleted file mode 100644 index 96e5d57f..00000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php +++ /dev/null @@ -1,128 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\FormatterInterface; -use Monolog\Formatter\ElasticaFormatter; -use Monolog\Logger; -use Elastica\Client; -use Elastica\Exception\ExceptionInterface; - -/** - * Elastic Search handler - * - * Usage example: - * - * $client = new \Elastica\Client(); - * $options = array( - * 'index' => 'elastic_index_name', - * 'type' => 'elastic_doc_type', - * ); - * $handler = new ElasticSearchHandler($client, $options); - * $log = new Logger('application'); - * $log->pushHandler($handler); - * - * @author Jelle Vink - */ -class ElasticSearchHandler extends AbstractProcessingHandler -{ - /** - * @var Client - */ - protected $client; - - /** - * @var array Handler config options - */ - protected $options = array(); - - /** - * @param Client $client Elastica Client object - * @param array $options Handler configuration - * @param integer $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct(Client $client, array $options = array(), $level = Logger::DEBUG, $bubble = true) - { - parent::__construct($level, $bubble); - $this->client = $client; - $this->options = array_merge( - array( - 'index' => 'monolog', // Elastic index name - 'type' => 'record', // Elastic document type - 'ignore_error' => false, // Suppress Elastica exceptions - ), - $options - ); - } - - /** - * {@inheritDoc} - */ - protected function write(array $record) - { - $this->bulkSend(array($record['formatted'])); - } - - /** - * {@inheritdoc} - */ - public function setFormatter(FormatterInterface $formatter) - { - if ($formatter instanceof ElasticaFormatter) { - return parent::setFormatter($formatter); - } - throw new \InvalidArgumentException('ElasticSearchHandler is only compatible with ElasticaFormatter'); - } - - /** - * Getter options - * @return array - */ - public function getOptions() - { - return $this->options; - } - - /** - * {@inheritDoc} - */ - protected function getDefaultFormatter() - { - return new ElasticaFormatter($this->options['index'], $this->options['type']); - } - - /** - * {@inheritdoc} - */ - public function handleBatch(array $records) - { - $documents = $this->getFormatter()->formatBatch($records); - $this->bulkSend($documents); - } - - /** - * Use Elasticsearch bulk API to send list of documents - * @param array $documents - * @throws \RuntimeException - */ - protected function bulkSend(array $documents) - { - try { - $this->client->addDocuments($documents); - } catch (ExceptionInterface $e) { - if (!$this->options['ignore_error']) { - throw new \RuntimeException("Error sending messages to Elasticsearch", 0, $e); - } - } - } -} -- cgit v1.2.2