ElasticaFormatter
extends NormalizerFormatter
in package
Format a log message into an Elastica Document
Tags
Table of Contents
Constants
- SIMPLE_DATE = "Y-m-d\\TH:i:sP"
Properties
- $basePath : string
- $dateFormat : string
- $index : string
- $maxNormalizeDepth : int
- $maxNormalizeItemCount : int
- $type : string|null
Methods
- __construct() : mixed
- addJsonEncodeOption() : $this
- 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
- normalizeValue() : null|scalar|array<string|int, array<string|int, mixed>|scalar|null>
- Normalize an arbitrary value to a scalar|array|null
- removeJsonEncodeOption() : $this
- setBasePath() : $this
- Setting a base path will hide the base path from exception and stack trace file names to shorten them
- setDateFormat() : $this
- setJsonPrettyPrint() : $this
- Enables `json_encode` pretty print.
- setMaxNormalizeDepth() : $this
- setMaxNormalizeItemCount() : $this
- formatDate() : string
- getDocument() : Document
- Convert a log message into an Elastica Document
- normalize() : null|scalar|array<string|int, array<string|int, mixed>|scalar|null>
- normalizeException() : array<string|int, mixed>
- normalizeRecord() : array<string|int, array<string|int, mixed>|scalar|null>
- Provided as extension point
- toJson() : string
- Return the JSON representation of a value
Constants
SIMPLE_DATE
public
mixed
SIMPLE_DATE
= "Y-m-d\\TH:i:sP"
Properties
$basePath
protected
string
$basePath
= ''
$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
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
Tags
addJsonEncodeOption()
public
addJsonEncodeOption(int $option) : $this
Parameters
- $option : int
Return values
$thisformat()
Formats a log record.
public
format(LogRecord $record) : mixed
Parameters
- $record : LogRecord
-
A record to format
Tags
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
Tags
Return values
mixed —The formatted set of records
getDateFormat()
public
getDateFormat() : string
Return values
stringgetIndex()
public
getIndex() : string
Return values
stringgetMaxNormalizeDepth()
The maximum number of normalization levels to go through
public
getMaxNormalizeDepth() : int
Return values
intgetMaxNormalizeItemCount()
The maximum number of items to normalize per level
public
getMaxNormalizeItemCount() : int
Return values
intgetType()
public
getType() : string
since Elastica 7 type has no effect
Return values
stringnormalizeValue()
Normalize an arbitrary value to a scalar|array|null
public
normalizeValue(mixed $data) : null|scalar|array<string|int, array<string|int, mixed>|scalar|null>
Parameters
- $data : mixed
Return values
null|scalar|array<string|int, array<string|int, mixed>|scalar|null>removeJsonEncodeOption()
public
removeJsonEncodeOption(int $option) : $this
Parameters
- $option : int
Return values
$thissetBasePath()
Setting a base path will hide the base path from exception and stack trace file names to shorten them
public
setBasePath([string $path = '' ]) : $this
Parameters
- $path : string = ''
Return values
$thissetDateFormat()
public
setDateFormat(string $dateFormat) : $this
Parameters
- $dateFormat : string
Return values
$thissetJsonPrettyPrint()
Enables `json_encode` pretty print.
public
setJsonPrettyPrint(bool $enable) : $this
Parameters
- $enable : bool
Return values
$thissetMaxNormalizeDepth()
public
setMaxNormalizeDepth(int $maxNormalizeDepth) : $this
Parameters
- $maxNormalizeDepth : int
Return values
$thissetMaxNormalizeItemCount()
public
setMaxNormalizeItemCount(int $maxNormalizeItemCount) : $this
Parameters
- $maxNormalizeItemCount : int
Return values
$thisformatDate()
protected
formatDate(DateTimeInterface $date) : string
Parameters
- $date : DateTimeInterface
Return values
stringgetDocument()
Convert a log message into an Elastica Document
protected
getDocument(array<string|int, mixed> $record) : Document
Parameters
- $record : array<string|int, mixed>
Return values
Documentnormalize()
protected
normalize(mixed $data[, int $depth = 0 ]) : null|scalar|array<string|int, array<string|int, mixed>|scalar|null>
Parameters
- $data : mixed
- $depth : int = 0
Return values
null|scalar|array<string|int, array<string|int, mixed>|scalar|null>normalizeException()
protected
normalizeException(Throwable $e[, int $depth = 0 ]) : array<string|int, mixed>
Parameters
- $e : Throwable
- $depth : int = 0
Return values
array<string|int, mixed>normalizeRecord()
Provided as extension point
protected
normalizeRecord(LogRecord $record) : array<string|int, array<string|int, mixed>|scalar|null>
Because normalize is called with sub-values of context data etc, normalizeRecord can be extended when data needs to be appended on the record array but not to other normalized data.
Parameters
- $record : LogRecord
Return values
array<string|int, array<string|int, mixed>|scalar|null>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