GelfMessageFormatter
extends NormalizerFormatter
in package
Serializes a log message to GELF
Tags
Table of Contents
Constants
- DEFAULT_MAX_LENGTH = 32766
- SIMPLE_DATE = "Y-m-d H:i:s"
Properties
- $contextPrefix : string
- $dateFormat : mixed
- $extraPrefix : string
- $maxLength : int
- $systemName : string
- $logLevels : mixed
- Translates Monolog log levels to Graylog2 log priorities.
Methods
- __construct() : mixed
- format() : mixed
- Formats a log record.
- formatBatch() : mixed
- Formats a set of log records.
- normalize() : mixed
- normalizeException() : mixed
- toJson() : string
- Return the JSON representation of a value
Constants
DEFAULT_MAX_LENGTH
public
mixed
DEFAULT_MAX_LENGTH
= 32766
SIMPLE_DATE
public
mixed
SIMPLE_DATE
= "Y-m-d H:i:s"
Properties
$contextPrefix
protected
string
$contextPrefix
a prefix for 'context' fields from the Monolog record (optional)
$dateFormat
protected
mixed
$dateFormat
$extraPrefix
protected
string
$extraPrefix
a prefix for 'extra' fields from the Monolog record (optional)
$maxLength
protected
int
$maxLength
max length per field
$systemName
protected
string
$systemName
the name of the system for the Gelf log message
$logLevels
Translates Monolog log levels to Graylog2 log priorities.
private
mixed
$logLevels
= array(\Monolog\Logger::DEBUG => 7, \Monolog\Logger::INFO => 6, \Monolog\Logger::NOTICE => 5, \Monolog\Logger::WARNING => 4, \Monolog\Logger::ERROR => 3, \Monolog\Logger::CRITICAL => 2, \Monolog\Logger::ALERT => 1, \Monolog\Logger::EMERGENCY => 0)
Methods
__construct()
public
__construct([mixed $systemName = null ][, mixed $extraPrefix = null ][, mixed $contextPrefix = 'ctxt_' ][, mixed $maxLength = null ]) : mixed
Parameters
- $systemName : mixed = null
- $extraPrefix : mixed = null
- $contextPrefix : mixed = 'ctxt_'
- $maxLength : mixed = null
format()
Formats a log record.
public
format(array<string|int, mixed> $record) : mixed
Parameters
- $record : array<string|int, mixed>
-
A record to format
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
normalize()
protected
normalize(mixed $data[, mixed $depth = 0 ]) : mixed
Parameters
- $data : mixed
- $depth : mixed = 0
normalizeException()
protected
normalizeException(mixed $e) : mixed
Parameters
- $e : mixed
toJson()
Return the JSON representation of a value
protected
toJson(mixed $data[, bool $ignoreErrors = false ]) : string
Parameters
- $data : mixed
- $ignoreErrors : bool = false