ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
Monolog\Formatter\FluentdFormatter Class Reference

Class FluentdFormatter. More...

+ Inheritance diagram for Monolog\Formatter\FluentdFormatter:
+ Collaboration diagram for Monolog\Formatter\FluentdFormatter:

Public Member Functions

 __construct ($levelTag=false)
 
 isUsingLevelsInTag ()
 
 format (array $record)
 Formats a log record. More...
 
 formatBatch (array $records)
 Formats a set of log records. More...
 

Protected Attributes

 $levelTag = false
 

Detailed Description

Class FluentdFormatter.

Serializes a log message to Fluentd unix socket protocol

Fluentd config:

<source> type unix path /var/run/td-agent/td-agent.sock </source>

Monolog setup:

$logger = new Monolog('fluent.tag'); $fluentHandler = new Monolog('unix:///var/run/td-agent/td-agent.sock'); $fluentHandler->setFormatter(new Monolog()); $logger->pushHandler($fluentHandler);

Author
Andrius Putna fordn.nosp@m.ox@g.nosp@m.mail..nosp@m.com

Definition at line 35 of file FluentdFormatter.php.

Constructor & Destructor Documentation

◆ __construct()

Monolog\Formatter\FluentdFormatter::__construct (   $levelTag = false)

Definition at line 42 of file FluentdFormatter.php.

References Monolog\Formatter\FluentdFormatter\$levelTag.

43  {
44  if (!function_exists('json_encode')) {
45  throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s FluentdUnixFormatter');
46  }
47 
48  $this->levelTag = (bool) $levelTag;
49  }

Member Function Documentation

◆ format()

Monolog\Formatter\FluentdFormatter::format ( array  $record)

Formats a log record.

Parameters
array$recordA record to format
Returns
mixed The formatted record

Implements Monolog\Formatter\FormatterInterface.

Definition at line 56 of file FluentdFormatter.php.

References array.

Referenced by Monolog\Formatter\FluentdFormatter\formatBatch().

57  {
58  $tag = $record['channel'];
59  if ($this->levelTag) {
60  $tag .= '.' . strtolower($record['level_name']);
61  }
62 
63  $message = array(
64  'message' => $record['message'],
65  'extra' => $record['extra'],
66  );
67 
68  if (!$this->levelTag) {
69  $message['level'] = $record['level'];
70  $message['level_name'] = $record['level_name'];
71  }
72 
73  return json_encode(array($tag, $record['datetime']->getTimestamp(), $message));
74  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ formatBatch()

Monolog\Formatter\FluentdFormatter::formatBatch ( array  $records)

Formats a set of log records.

Parameters
array$recordsA set of records to format
Returns
mixed The formatted set of records

Implements Monolog\Formatter\FormatterInterface.

Definition at line 76 of file FluentdFormatter.php.

References Monolog\Formatter\FluentdFormatter\format().

77  {
78  $message = '';
79  foreach ($records as $record) {
80  $message .= $this->format($record);
81  }
82 
83  return $message;
84  }
format(array $record)
Formats a log record.
$records
Definition: simple_test.php:22
+ Here is the call graph for this function:

◆ isUsingLevelsInTag()

Monolog\Formatter\FluentdFormatter::isUsingLevelsInTag ( )

Field Documentation

◆ $levelTag

Monolog\Formatter\FluentdFormatter::$levelTag = false
protected

The documentation for this class was generated from the following file: