Documentation

LogmaticFormatter extends JsonFormatter
in package

Encodes message information into JSON in a format compatible with Logmatic.

Tags
author

Julien Breux julien.breux@gmail.com

Table of Contents

BATCH_MODE_JSON  = 1
BATCH_MODE_NEWLINES  = 2
SIMPLE_DATE  = "Y-m-d H:i:s"
MARKERS  = ["sourcecode", "php"]
$appendNewline  : mixed
$appname  : string
$batchMode  : mixed
$dateFormat  : mixed
$hostname  : string
$includeStacktraces  : bool
__construct()  : mixed
format()  : mixed
Appends the 'hostname' and 'appname' parameter for indexing by Logmatic.
formatBatch()  : mixed
Formats a set of log records.
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.
includeStacktraces()  : mixed
isAppendingNewlines()  : bool
True if newlines are appended to every formatted record
setAppname()  : self
setHostname()  : self
formatBatchJson()  : string
Return a JSON-encoded array of records.
formatBatchNewlines()  : string
Use new lines to separate records instead of a JSON-encoded array.
normalize()  : mixed
normalizeException()  : mixed
toJson()  : string
Return the JSON representation of a value

Constants

Properties

$includeStacktraces

protected bool $includeStacktraces = false

Methods

__construct()

public __construct([string $dateFormat = null ]) : mixed
Parameters
$dateFormat : string = null

The format of the timestamp: one supported by DateTime::format

Return values
mixed

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

getBatchMode()

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.

public getBatchMode() : int
Return values
int

includeStacktraces()

public includeStacktraces([bool $include = true ]) : mixed
Parameters
$include : bool = true
Return values
mixed

isAppendingNewlines()

True if newlines are appended to every formatted record

public isAppendingNewlines() : bool
Return values
bool

setAppname()

public setAppname(string $appname) : self
Parameters
$appname : string
Return values
self

setHostname()

public setHostname(string $hostname) : self
Parameters
$hostname : string
Return values
self

formatBatchJson()

Return a JSON-encoded array of records.

protected formatBatchJson(array<string|int, mixed> $records) : string
Parameters
$records : array<string|int, mixed>
Return values
string

formatBatchNewlines()

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

protected formatBatchNewlines(array<string|int, mixed> $records) : string
Parameters
$records : array<string|int, mixed>
Return values
string

normalize()

protected normalize(mixed $data, mixed $depth) : mixed
Parameters
$data : mixed
$depth : mixed
Return values
mixed

normalizeException()

protected normalizeException(mixed $e) : mixed
Parameters
$e : mixed
Return values
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

Search results