1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-25 02:26:16 +02:00

Rename ElasticSearch to Elasticsearch

This commit is contained in:
Avtandil Kikabidze
2018-06-27 11:48:39 +04:00
parent 34e3a48326
commit 4c7795d310
7 changed files with 67 additions and 67 deletions

View File

@@ -14,29 +14,29 @@ namespace Monolog\Formatter;
use DateTime;
/**
* Format a log message into an ElasticSearch record
* Format a log message into an Elasticsearch record
*
* @author Avtandil Kikabidze <akalongman@gmail.com>
*/
class ElasticSearchFormatter extends NormalizerFormatter
class ElasticsearchFormatter extends NormalizerFormatter
{
/**
* @var string ElasticSearch index name
* @var string Elasticsearch index name
*/
protected $index;
/**
* @var string ElasticSearch record type
* @var string Elasticsearch record type
*/
protected $type;
/**
* @param string $index ElasticSearch index name
* @param string $type ElasticSearch record type
* @param string $index Elasticsearch index name
* @param string $type Elasticsearch record type
*/
public function __construct($index, $type)
{
// ElasticSearch requires an ISO 8601 format date with optional millisecond precision.
// Elasticsearch requires an ISO 8601 format date with optional millisecond precision.
parent::__construct(DateTime::ISO8601);
$this->index = $index;
@@ -74,7 +74,7 @@ class ElasticSearchFormatter extends NormalizerFormatter
}
/**
* Convert a log message into an ElasticSearch record
* Convert a log message into an Elasticsearch record
*
* @param array $record Log message
* @return array

View File

@@ -12,36 +12,36 @@
namespace Monolog\Handler;
use Elasticsearch\Client;
use Elasticsearch\Common\Exceptions\RuntimeException as ElasticSearchRuntimeException;
use Elasticsearch\Common\Exceptions\RuntimeException as ElasticsearchRuntimeException;
use InvalidArgumentException;
use Monolog\Formatter\ElasticSearchFormatter;
use Monolog\Formatter\ElasticsearchFormatter;
use Monolog\Formatter\FormatterInterface;
use Monolog\Logger;
use RuntimeException;
use Throwable;
/**
* Elastic Search handler
* Elasticsearch handler
*
* @link https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html
*
* Simple usage example:
*
* $client = \ElasticSearch\ClientBuilder::create()
* $client = \Elasticsearch\ClientBuilder::create()
* ->setHosts($hosts)
* ->build();
*
* $options = array(
* 'index' => 'elastic_index_name',
* 'type' => 'elastic_doc_type',
* 'type' => 'elastic_doc_type',
* );
* $handler = new ElasticSearchHandler($client, $options);
* $handler = new ElasticsearchHandler($client, $options);
* $log = new Logger('application');
* $log->pushHandler($handler);
*
* @author Avtandil Kikabidze <akalongman@gmail.com>
*/
class ElasticSearchHandler extends AbstractProcessingHandler
class ElasticsearchHandler extends AbstractProcessingHandler
{
/**
* @var \Elasticsearch\Client
@@ -54,7 +54,7 @@ class ElasticSearchHandler extends AbstractProcessingHandler
protected $options = [];
/**
* @param \Elasticsearch\Client $client ElasticSearch Client object
* @param \Elasticsearch\Client $client Elasticsearch Client object
* @param array $options Handler configuration
* @param int $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
@@ -67,7 +67,7 @@ class ElasticSearchHandler extends AbstractProcessingHandler
[
'index' => 'monolog', // Elastic index name
'type' => '_doc', // Elastic document type
'ignore_error' => false, // Suppress ElasticSearch exceptions
'ignore_error' => false, // Suppress Elasticsearch exceptions
],
$options
);
@@ -86,10 +86,10 @@ class ElasticSearchHandler extends AbstractProcessingHandler
*/
public function setFormatter(FormatterInterface $formatter): HandlerInterface
{
if ($formatter instanceof ElasticSearchFormatter) {
if ($formatter instanceof ElasticsearchFormatter) {
return parent::setFormatter($formatter);
}
throw new InvalidArgumentException('ElasticSearchHandler is only compatible with ElasticSearchFormatter');
throw new InvalidArgumentException('ElasticsearchHandler is only compatible with ElasticsearchFormatter');
}
/**
@@ -107,7 +107,7 @@ class ElasticSearchHandler extends AbstractProcessingHandler
*/
protected function getDefaultFormatter(): FormatterInterface
{
return new ElasticSearchFormatter($this->options['index'], $this->options['type']);
return new ElasticsearchFormatter($this->options['index'], $this->options['type']);
}
/**
@@ -120,7 +120,7 @@ class ElasticSearchHandler extends AbstractProcessingHandler
}
/**
* Use ElasticSearch bulk API to send list of documents
* Use Elasticsearch bulk API to send list of documents
*
* @param array $records
* @throws \RuntimeException
@@ -147,11 +147,11 @@ class ElasticSearchHandler extends AbstractProcessingHandler
$responses = $this->client->bulk($params);
if ($responses['errors'] === true) {
throw new ElasticSearchRuntimeException('ElasticSearch returned error for one of the records');
throw new ElasticsearchRuntimeException('Elasticsearch returned error for one of the records');
}
} catch (Throwable $e) {
if (! $this->options['ignore_error']) {
throw new RuntimeException('Error sending messages to ElasticSearch', 0, $e);
throw new RuntimeException('Error sending messages to Elasticsearch', 0, $e);
}
}
}