LogglyFormatter
extends JsonFormatter
in package
Encodes message information into JSON in a format compatible with Loggly.
Tags
Table of Contents
Constants
- BATCH_MODE_JSON = 1
- BATCH_MODE_NEWLINES = 2
- SIMPLE_DATE = "Y-m-d H:i:s"
Properties
- $appendNewline : mixed
- $batchMode : mixed
- $dateFormat : mixed
- $includeStacktraces : bool
Methods
- __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
- Normalizes given $data.
- normalizeException() : array<string|int, mixed>
- Normalizes given exception with or without its own stack trace based on `includeStacktraces` property.
- 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
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
intincludeStacktraces()
public
includeStacktraces([bool $include = true ]) : mixed
Parameters
- $include : bool = true
isAppendingNewlines()
True if newlines are appended to every formatted record
public
isAppendingNewlines() : bool
Return values
boolformatBatchJson()
Return a JSON-encoded array of records.
protected
formatBatchJson(array<string|int, mixed> $records) : string
Parameters
- $records : array<string|int, mixed>
Return values
stringformatBatchNewlines()
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
stringnormalize()
Normalizes given $data.
protected
normalize(mixed $data[, mixed $depth = 0 ]) : mixed
Parameters
- $data : mixed
- $depth : mixed = 0
normalizeException()
Normalizes given exception with or without its own stack trace based on `includeStacktraces` property.
protected
normalizeException(Exception|Throwable $e) : array<string|int, mixed>
Parameters
- $e : Exception|Throwable
Return values
array<string|int, mixed>toJson()
Return the JSON representation of a value
protected
toJson(mixed $data[, bool $ignoreErrors = false ]) : string
Parameters
- $data : mixed
- $ignoreErrors : bool = false