ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
GelfHandler.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\Handler;
13
14use Gelf\IMessagePublisher;
15use Gelf\PublisherInterface;
16use Gelf\Publisher;
17use InvalidArgumentException;
20
28{
32 protected $publisher;
33
40 {
41 parent::__construct($level, $bubble);
42
43 if (!$publisher instanceof Publisher && !$publisher instanceof IMessagePublisher && !$publisher instanceof PublisherInterface) {
44 throw new InvalidArgumentException("Invalid publisher, expected a Gelf\Publisher, Gelf\IMessagePublisher or Gelf\PublisherInterface instance");
45 }
46
47 $this->publisher = $publisher;
48 }
49
53 public function close()
54 {
55 $this->publisher = null;
56 }
57
61 protected function write(array $record)
62 {
63 $this->publisher->publish($record['formatted']);
64 }
65
69 protected function getDefaultFormatter()
70 {
71 return new GelfMessageFormatter();
72 }
73}
Serializes a log message to GELF.
Base Handler class providing the Handler structure.
Handler to send messages to a Graylog2 (http://www.graylog2.org) server.
Definition: GelfHandler.php:28
write(array $record)
{Writes the record down to the log of the implementing handler.void}
Definition: GelfHandler.php:61
close()
{Closes the handler.This will be called automatically when the object is destroyed}
Definition: GelfHandler.php:53
getDefaultFormatter()
Gets the default formatter.FormatterInterface
Definition: GelfHandler.php:69
__construct($publisher, $level=Logger::DEBUG, $bubble=true)
Definition: GelfHandler.php:39
Monolog log channel.
Definition: Logger.php:28
const DEBUG
Detailed debug information.
Definition: Logger.php:32