LogstashFormatter
extends NormalizerFormatter
in package
Serializes a log message to Logstash Event Format
Tags
Table of Contents
Constants
- SIMPLE_DATE = "Y-m-d H:i:s"
- V0 = 0
- V1 = 1
Properties
- $applicationName : string
- $contextPrefix : string
- $dateFormat : mixed
- $extraPrefix : string
- $systemName : string
- $version : int
Methods
- __construct() : mixed
- format() : mixed
- Formats a log record.
- formatBatch() : mixed
- Formats a set of log records.
- formatV0() : mixed
- formatV1() : mixed
- normalize() : mixed
- normalizeException() : mixed
- toJson() : string
- Return the JSON representation of a value
Constants
SIMPLE_DATE
public
mixed
SIMPLE_DATE
= "Y-m-d H:i:s"
V0
public
mixed
V0
= 0
V1
public
mixed
V1
= 1
Properties
$applicationName
protected
string
$applicationName
an application name for the Logstash log message, used to fill the @type field
$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)
$systemName
protected
string
$systemName
the name of the system for the Logstash log message, used to fill the @source field
$version
protected
int
$version
logstash format version to use
Methods
__construct()
public
__construct(string $applicationName[, string $systemName = null ][, string $extraPrefix = null ][, string $contextPrefix = 'ctxt_' ][, int $version = self::V0 ]) : mixed
Parameters
- $applicationName : string
-
the application that sends the data, used as the "type" field of logstash
- $systemName : string = null
-
the system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine
- $extraPrefix : string = null
-
prefix for extra keys inside logstash "fields"
- $contextPrefix : string = 'ctxt_'
-
prefix for context keys inside logstash "fields", defaults to ctxt_
- $version : int = self::V0
-
the logstash format version to use, defaults to 0
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
formatV0()
protected
formatV0(array<string|int, mixed> $record) : mixed
Parameters
- $record : array<string|int, mixed>
formatV1()
protected
formatV1(array<string|int, mixed> $record) : mixed
Parameters
- $record : array<string|int, mixed>
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