LogglyFormatter
extends JsonFormatter
in package
Encodes message information into JSON in a format compatible with Loggly.
Tags
Table of Contents
- BATCH_MODE_JSON = 1
- BATCH_MODE_NEWLINES = 2
- SIMPLE_DATE = "Y-m-d H:i:s"
- $appendNewline : mixed
- $batchMode : mixed
- $dateFormat : mixed
- $includeStacktraces : bool
- __construct() : mixed
- Overrides the default batch mode to new lines for compatibility with the Loggly bulk API.
- format() : mixed
- Appends the 'timestamp' parameter for indexing by Loggly.
- formatBatch() : mixed
- Formats a set of log records.
- getBatchMode() : int
- The batch mode option configures the formatting style for multiple records. By default, multiple records will be formatted as a JSON-encoded array. However, for compatibility with some API endpoints, alternative styles are available.
- includeStacktraces() : mixed
- isAppendingNewlines() : bool
- True if newlines are appended to every formatted record
- formatBatchJson() : string
- Return a JSON-encoded array of records.
- formatBatchNewlines() : string
- Use new lines to separate records instead of a JSON-encoded array.
- normalize() : mixed
- normalizeException() : mixed
- toJson() : string
- Return the JSON representation of a value
Constants
BATCH_MODE_JSON
public
mixed
BATCH_MODE_JSON
= 1
BATCH_MODE_NEWLINES
public
mixed
BATCH_MODE_NEWLINES
= 2
SIMPLE_DATE
public
mixed
SIMPLE_DATE
= "Y-m-d H:i:s"
Properties
$appendNewline
protected
mixed
$appendNewline
$batchMode
protected
mixed
$batchMode
$dateFormat
protected
mixed
$dateFormat
$includeStacktraces
protected
bool
$includeStacktraces
= false
Methods
__construct()
Overrides the default batch mode to new lines for compatibility with the Loggly bulk API.
public
__construct([int $batchMode = self::BATCH_MODE_NEWLINES ][, mixed $appendNewline = false ]) : mixed
Parameters
- $batchMode : int = self::BATCH_MODE_NEWLINES
- $appendNewline : mixed = false
Return values
mixed —format()
Appends the 'timestamp' parameter for indexing by Loggly.
public
format(array<string|int, mixed> $record) : mixed
Parameters
- $record : array<string|int, mixed>
-
A record to format
Tags
Return values
mixed —The formatted record
formatBatch()
Formats a set of log records.
public
formatBatch(array<string|int, mixed> $records) : mixed
Parameters
- $records : array<string|int, mixed>
-
A set of records to format
Return values
mixed —The formatted set of records
getBatchMode()
The batch mode option configures the formatting style for multiple records. By default, multiple records will be formatted as a JSON-encoded array. However, for compatibility with some API endpoints, alternative styles are available.
public
getBatchMode() : int
Return values
int —includeStacktraces()
public
includeStacktraces([bool $include = true ]) : mixed
Parameters
- $include : bool = true
Return values
mixed —isAppendingNewlines()
True if newlines are appended to every formatted record
public
isAppendingNewlines() : bool
Return values
bool —formatBatchJson()
Return a JSON-encoded array of records.
protected
formatBatchJson(array<string|int, mixed> $records) : string
Parameters
- $records : array<string|int, mixed>
Return values
string —formatBatchNewlines()
Use new lines to separate records instead of a JSON-encoded array.
protected
formatBatchNewlines(array<string|int, mixed> $records) : string
Parameters
- $records : array<string|int, mixed>
Return values
string —normalize()
protected
normalize(mixed $data, mixed $depth) : mixed
Parameters
- $data : mixed
- $depth : mixed
Return values
mixed —normalizeException()
protected
normalizeException(mixed $e) : mixed
Parameters
- $e : mixed
Return values
mixed —toJson()
Return the JSON representation of a value
protected
toJson(mixed $data[, bool $ignoreErrors = false ]) : string
Parameters
- $data : mixed
- $ignoreErrors : bool = false