Constants

SIMPLE_DATE

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

DEFAULT_MAX_LENGTH

DEFAULT_MAX_LENGTH = 32766

Properties

$dateFormat

$dateFormat : string

Type

string

$maxNormalizeDepth

$maxNormalizeDepth : int

Type

int

$maxNormalizeItemCount

$maxNormalizeItemCount : int

Type

int

$systemName

$systemName : string

Type

string — the name of the system for the Gelf log message

$extraPrefix

$extraPrefix : string

Type

string — a prefix for 'extra' fields from the Monolog record (optional)

$contextPrefix

$contextPrefix : string

Type

string — a prefix for 'context' fields from the Monolog record (optional)

$maxLength

$maxLength : int

Type

int — max length per field

$jsonEncodeOptions

$jsonEncodeOptions : int

Type

int

$gelfVersion

$gelfVersion : int

Type

int

$logLevels

$logLevels : array<int,int>

Translates Monolog log levels to Graylog2 log priorities.

Type

array

Methods

__construct()

__construct(?string  $systemName = null, ?string  $extraPrefix = null, string  $contextPrefix = 'ctxt_', ?int  $maxLength = null) : mixed

Parameters

?string $systemName
?string $extraPrefix
string $contextPrefix
?int $maxLength

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 —

normalize()

normalize(mixed  $data, int  $depth) : null|scalar|(array|scalar|null)[]

Parameters

mixed $data
int $depth

Returns

null|scalar|(array|scalar|null)[] —

normalizeException()

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

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 —