<?php /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Formatter; use Elastica\Document; /** * Format a log message into an Elastica Document * * @author Jelle Vink <jelle.vink@gmail.com> */ class ElasticaFormatter extends NormalizerFormatter { /** * @var string Elastic search index name */ protected $index; /** * @var string Elastic search document type */ protected $type; /** * @param string $index Elastic Search index name * @param string $type Elastic Search document type */ public function __construct($index, $type) { // elasticsearch requires a ISO 8601 format date with optional millisecond precision. parent::__construct('Y-m-d\TH:i:s.uP'); $this->index = $index; $this->type = $type; } /** * {@inheritdoc} */ public function format(array $record) { $record = parent::format($record); return $this->getDocument($record); } /** * Getter index * @return string */ public function getIndex() { return $this->index; } /** * Getter type * @return string */ public function getType() { return $this->type; } /** * Convert a log message into an Elastica Document * * @param array $record Log message * @return Document */ protected function getDocument($record) { $document = new Document(); $document->setData($record); $document->setType($this->type); $document->setIndex($this->index); return $document; } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
ChromePHPFormatter.php | File | 2 KB | 0644 |
|
ElasticaFormatter.php | File | 1.79 KB | 0644 |
|
FlowdockFormatter.php | File | 2.49 KB | 0644 |
|
FluentdFormatter.php | File | 2.11 KB | 0644 |
|
FormatterInterface.php | File | 787 B | 0644 |
|
GelfMessageFormatter.php | File | 4.3 KB | 0644 |
|
HtmlFormatter.php | File | 4.46 KB | 0644 |
|
JsonFormatter.php | File | 5.53 KB | 0644 |
|
LineFormatter.php | File | 5.44 KB | 0644 |
|
LogglyFormatter.php | File | 1.29 KB | 0644 |
|
LogstashFormatter.php | File | 5.18 KB | 0644 |
|
MongoDBFormatter.php | File | 3.21 KB | 0644 |
|
NormalizerFormatter.php | File | 9.91 KB | 0644 |
|
ScalarFormatter.php | File | 1.02 KB | 0644 |
|
WildfireFormatter.php | File | 3.18 KB | 0644 |
|