ElasticaFormatter
extends NormalizerFormatter
in package
Format a log message into an Elastica Document
Tags
Table of Contents
- SIMPLE_DATE = "Y-m-d\TH:i:sP"
- $dateFormat : string
- $index : string
- $maxNormalizeDepth : int
- $maxNormalizeItemCount : int
- $type : string|null
- $jsonEncodeOptions : int
- __construct() : mixed
- addJsonEncodeOption() : self
- format() : mixed
- Formats a log record.
- formatBatch() : mixed
- Formats a set of log records.
- getDateFormat() : string
- getIndex() : string
- getMaxNormalizeDepth() : int
- The maximum number of normalization levels to go through
- getMaxNormalizeItemCount() : int
- The maximum number of items to normalize per level
- getType() : string
- removeJsonEncodeOption() : self
- setDateFormat() : self
- setJsonPrettyPrint() : self
- Enables `json_encode` pretty print.
- setMaxNormalizeDepth() : self
- setMaxNormalizeItemCount() : self
- formatDate() : string
- getDocument() : Document
- Convert a log message into an Elastica Document
- normalize() : null|scalar|array<string|int, array|scalar|null>
- normalizeException() : array<string|int, mixed>
- toJson() : string
- Return the JSON representation of a value
Constants
SIMPLE_DATE
public
mixed
SIMPLE_DATE
= "Y-m-d\TH:i:sP"
Properties
$dateFormat
protected
string
$dateFormat
$index
protected
string
$index
Elastic search index name
$maxNormalizeDepth
protected
int
$maxNormalizeDepth
= 9
$maxNormalizeItemCount
protected
int
$maxNormalizeItemCount
= 1000
$type
protected
string|null
$type
Elastic search document type
$jsonEncodeOptions
private
int
$jsonEncodeOptions
= MonologUtils::DEFAULT_JSON_FLAGS
Methods
__construct()
public
__construct(string $index, string|null $type) : mixed
Parameters
- $index : string
-
Elastic Search index name
- $type : string|null
-
Elastic Search document type, deprecated as of Elastica 7
Return values
mixed —addJsonEncodeOption()
public
addJsonEncodeOption(int $option) : self
Parameters
- $option : int
Return values
self —format()
Formats a log record.
public
format(array<string|int, mixed> $record) : mixed
Parameters
- $record : array<string|int, mixed>
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
getDateFormat()
public
getDateFormat() : string
Return values
string —getIndex()
public
getIndex() : string
Return values
string —getMaxNormalizeDepth()
The maximum number of normalization levels to go through
public
getMaxNormalizeDepth() : int
Return values
int —getMaxNormalizeItemCount()
The maximum number of items to normalize per level
public
getMaxNormalizeItemCount() : int
Return values
int —getType()
public
getType() : string
Tags
Return values
string —removeJsonEncodeOption()
public
removeJsonEncodeOption(int $option) : self
Parameters
- $option : int
Return values
self —setDateFormat()
public
setDateFormat(string $dateFormat) : self
Parameters
- $dateFormat : string
Return values
self —setJsonPrettyPrint()
Enables `json_encode` pretty print.
public
setJsonPrettyPrint(bool $enable) : self
Parameters
- $enable : bool
Return values
self —setMaxNormalizeDepth()
public
setMaxNormalizeDepth(int $maxNormalizeDepth) : self
Parameters
- $maxNormalizeDepth : int
Return values
self —setMaxNormalizeItemCount()
public
setMaxNormalizeItemCount(int $maxNormalizeItemCount) : self
Parameters
- $maxNormalizeItemCount : int
Return values
self —formatDate()
protected
formatDate(DateTimeInterface $date) : string
Parameters
- $date : DateTimeInterface
Return values
string —getDocument()
Convert a log message into an Elastica Document
protected
getDocument(array<string|int, mixed> $record) : Document
Parameters
- $record : array<string|int, mixed>
Tags
Return values
Document —normalize()
protected
normalize(mixed $data, int $depth) : null|scalar|array<string|int, array|scalar|null>
Parameters
- $data : mixed
- $depth : int
Return values
null|scalar|array<string|int, array|scalar|null> —normalizeException()
protected
normalizeException(Throwable $e, int $depth) : array<string|int, mixed>
Parameters
- $e : Throwable
- $depth : int
Return values
array<string|int, mixed> —toJson()
Return the JSON representation of a value
protected
toJson(mixed $data[, bool $ignoreErrors = false ]) : string
Parameters
- $data : mixed
- $ignoreErrors : bool = false
Tags
Return values
string —if encoding fails and ignoreErrors is true 'null' is returned