ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
Monolog\Formatter\LogglyFormatter Class Reference

Encodes message information into JSON in a format compatible with Loggly. More...

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

Public Member Functions

 __construct ($batchMode=self::BATCH_MODE_NEWLINES, $appendNewline=false)
 Overrides the default batch mode to new lines for compatibility with the Loggly bulk API. More...
 
 format (array $record)
 Appends the 'timestamp' parameter for indexing by Loggly. More...
 
- Public Member Functions inherited from Monolog\Formatter\JsonFormatter
 __construct ($batchMode=self::BATCH_MODE_JSON, $appendNewline=true)
 
 getBatchMode ()
 The batch mode option configures the formatting style for multiple records. More...
 
 isAppendingNewlines ()
 True if newlines are appended to every formatted record. More...
 
 format (array $record)
 {Formats a log record.
Parameters
array$recordA record to format
Returns
mixed The formatted record
} More...
 
 formatBatch (array $records)
 {Formats a set of log records.
Parameters
array$recordsA set of records to format
Returns
mixed The formatted set of records
} More...
 

Additional Inherited Members

- Data Fields inherited from Monolog\Formatter\JsonFormatter
const BATCH_MODE_JSON = 1
 
const BATCH_MODE_NEWLINES = 2
 
- Protected Member Functions inherited from Monolog\Formatter\JsonFormatter
 formatBatchJson (array $records)
 Return a JSON-encoded array of records. More...
 
 formatBatchNewlines (array $records)
 Use new lines to separate records instead of a JSON-encoded array. More...
 
- Protected Attributes inherited from Monolog\Formatter\JsonFormatter
 $batchMode
 
 $appendNewline
 

Detailed Description

Encodes message information into JSON in a format compatible with Loggly.

Author
Adam Pancutt adam@.nosp@m.panc.nosp@m.utt.c.nosp@m.om

Definition at line 19 of file LogglyFormatter.php.

Constructor & Destructor Documentation

◆ __construct()

Monolog\Formatter\LogglyFormatter::__construct (   $batchMode = self::BATCH_MODE_NEWLINES,
  $appendNewline = false 
)

Overrides the default batch mode to new lines for compatibility with the Loggly bulk API.

Parameters
integer$batchMode

Definition at line 27 of file LogglyFormatter.php.

References Monolog\Formatter\JsonFormatter\$appendNewline, and Monolog\Formatter\JsonFormatter\$batchMode.

Member Function Documentation

◆ format()

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

Appends the 'timestamp' parameter for indexing by Loggly.

See also
https://www.loggly.com/docs/automated-parsing/#json
::format()

Implements Monolog\Formatter\FormatterInterface.

Definition at line 38 of file LogglyFormatter.php.

39  {
40  if (isset($record["datetime"]) && ($record["datetime"] instanceof \DateTime)) {
41  $record["timestamp"] = $record["datetime"]->format("Y-m-d\TH:i:s.uO");
42  // TODO 2.0 unset the 'datetime' parameter, retained for BC
43  }
44 
45  return parent::format($record);
46  }

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