Constants

SIMPLE_DATE

SIMPLE_DATE = "Y-m-d\\TH:i:sP"

BATCH_MODE_JSON

BATCH_MODE_JSON = 1

BATCH_MODE_NEWLINES

BATCH_MODE_NEWLINES = 2

Properties

$dateFormat

$dateFormat : string

Type

string

$maxNormalizeDepth

$maxNormalizeDepth : int

Type

int

$maxNormalizeItemCount

$maxNormalizeItemCount : int

Type

int

$batchMode

$batchMode

$appendNewline

$appendNewline : bool

Type

bool

$ignoreEmptyContextAndExtra

$ignoreEmptyContextAndExtra : bool

Type

bool

$includeStacktraces

$includeStacktraces : bool

Type

bool

$jsonEncodeOptions

$jsonEncodeOptions : int

Type

int

Methods

__construct()

__construct(int  $batchMode = self::BATCH_MODE_JSON, bool  $appendNewline = true, bool  $ignoreEmptyContextAndExtra = false, bool  $includeStacktraces = false) : mixed

Parameters

int $batchMode
bool $appendNewline
bool $ignoreEmptyContextAndExtra
bool $includeStacktraces

Returns

mixed —

format()

format(array  $record) : mixed

Formats a log record.

Parameters

array $record

Returns

mixed —

The formatted record

formatBatch()

formatBatch(array  $records) : mixed

Formats a set of log records.

Parameters

array $records

A set of records to format

Returns

mixed —

The formatted set of records

getDateFormat()

getDateFormat() : string

Returns

string —

setDateFormat()

setDateFormat(string  $dateFormat) : self

Parameters

string $dateFormat

Returns

self —

getMaxNormalizeDepth()

getMaxNormalizeDepth() : int

The maximum number of normalization levels to go through

Returns

int —

setMaxNormalizeDepth()

setMaxNormalizeDepth(int  $maxNormalizeDepth) : self

Parameters

int $maxNormalizeDepth

Returns

self —

getMaxNormalizeItemCount()

getMaxNormalizeItemCount() : int

The maximum number of items to normalize per level

Returns

int —

setMaxNormalizeItemCount()

setMaxNormalizeItemCount(int  $maxNormalizeItemCount) : self

Parameters

int $maxNormalizeItemCount

Returns

self —

setJsonPrettyPrint()

setJsonPrettyPrint(bool  $enable) : self

Enables `json_encode` pretty print.

Parameters

bool $enable

Returns

self —

addJsonEncodeOption()

addJsonEncodeOption(int  $option) : self

Parameters

int $option

Returns

self —

removeJsonEncodeOption()

removeJsonEncodeOption(int  $option) : self

Parameters

int $option

Returns

self —

getBatchMode()

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.

Returns

int —

isAppendingNewlines()

isAppendingNewlines() : bool

True if newlines are appended to every formatted record

Returns

bool —

includeStacktraces()

includeStacktraces(bool  $include = true) : self

Parameters

bool $include

Returns

self —

normalize()

normalize(mixed  $data, int  $depth) : mixed

Normalizes given $data.

Parameters

mixed $data
int $depth

Returns

mixed —

normalizeException()

normalizeException(\Throwable  $e, int  $depth) : array

Normalizes given exception with or without its own stack trace based on `includeStacktraces` property.

{@inheritDoc}

Parameters

\Throwable $e
int $depth

Returns

array —

toJson()

toJson(mixed  $data, bool  $ignoreErrors = false) : string

Return the JSON representation of a value

Parameters

mixed $data
bool $ignoreErrors

Throws

\RuntimeException

if encoding fails and errors are not ignored

Returns

string —

if encoding fails and ignoreErrors is true 'null' is returned

formatDate()

formatDate(\DateTimeInterface  $date) : string

Parameters

\DateTimeInterface $date

Returns

string —

formatBatchJson()

formatBatchJson(array  $records) : string

Return a JSON-encoded array of records.

Parameters

array $records

Returns

string —

formatBatchNewlines()

formatBatchNewlines(array  $records) : string

Use new lines to separate records instead of a JSON-encoded array.

Parameters

array $records

Returns

string —