ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ElasticaFormatter.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of the Monolog package.
5 *
6 * (c) Jordi Boggiano <j.boggiano@seld.be>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Monolog\Formatter;
13
14use Elastica\Document;
15
22{
26 protected $index;
27
31 protected $type;
32
37 public function __construct($index, $type)
38 {
39 // elasticsearch requires a ISO 8601 format date with optional millisecond precision.
40 parent::__construct('Y-m-d\TH:i:s.uP');
41
42 $this->index = $index;
43 $this->type = $type;
44 }
45
49 public function format(array $record)
50 {
51 $record = parent::format($record);
52
53 return $this->getDocument($record);
54 }
55
60 public function getIndex()
61 {
62 return $this->index;
63 }
64
69 public function getType()
70 {
71 return $this->type;
72 }
73
80 protected function getDocument($record)
81 {
82 $document = new Document();
83 $document->setData($record);
84 $document->setType($this->type);
85 $document->setIndex($this->index);
86
87 return $document;
88 }
89}
An exception for terminatinating execution or to throw for unit testing.
Format a log message into an Elastica Document.
getDocument($record)
Convert a log message into an Elastica Document.
format(array $record)
{{Formats a log record.mixed The formatted record}}
Normalizes incoming records to remove objects/resources so it's easier to dump to various targets.