Documentation

LogstashFormatter extends NormalizerFormatter
in package

Serializes a log message to Logstash Event Format

Tags
see
http://logstash.net/
see
https://github.com/logstash/logstash/blob/master/lib/logstash/event.rb
author

Tim Mower timothy.mower@gmail.com

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

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)

$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

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

if encoding fails and errors are not ignored

Return values
string

        
On this page

Search results