ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 parent::__construct(\DateTime::ISO8601);
40 $this->index = $index;
41 $this->type = $type;
42 }
43
47 public function format(array $record)
48 {
49 $record = parent::format($record);
50
51 return $this->getDocument($record);
52 }
53
58 public function getIndex()
59 {
60 return $this->index;
61 }
62
67 public function getType()
68 {
69 return $this->type;
70 }
71
78 protected function getDocument($record)
79 {
80 $document = new Document();
81 $document->setData($record);
82 $document->setType($this->type);
83 $document->setIndex($this->index);
84
85 return $document;
86 }
87}
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.