Documentation

LogglyFormatter extends JsonFormatter
in package

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

Tags
author

Adam Pancutt adam@pancutt.com

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

Properties

$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

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

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()

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
Tags
throws
RuntimeException

if encoding fails and errors are not ignored

Return values
string

        
On this page

Search results