PHP Class yii\elasticsearch\ElasticsearchTarget

Since: 2.0.5
Author: Eugene Terentev ([email protected])
Inheritance: extends yii\log\Target
Datei anzeigen Open project: yiisoft/yii2-elasticsearch

Public Properties

Property Type Description
$cacheContext If true, context message will cached once it's been created. Makes sense to use with [[includeContext]].
$db the elasticsearch connection object or the application component ID of the elasticsearch connection.
$includeContext If true, context will be included in every message. This is convenient if you log application errors and analyze them with tools like Kibana.
$index Elasticsearch index name.
$logContext If true, context will be logged as a separate message after all other messages.
$options array URL options.
$type Elasticsearch type name.

Protected Properties

Property Type Description
$_contextMessage Context message cache (can be used multiple times if context is appended to every message)

Public Methods

Method Description
collect ( array $messages, boolean $final ) Processes the given log messages.
export ( )
init ( ) This method will initialize the [[elasticsearch]] property to make sure it refers to a valid Elasticsearch connection.
prepareMessage ( array $message ) : string Prepares a log message.

Protected Methods

Method Description
getContextMessage ( ) : array If [[includeContext]] property is false, returns context message normally.

Method Details

collect() public method

This method will filter the given messages with [[levels]] and [[categories]]. And if requested, it will also export the filtering result to specific medium (e.g. email). Depending on the [[includeContext]] attribute, a context message will be either created or ignored.
public collect ( array $messages, boolean $final )
$messages array log messages to be processed. See [[Logger::messages]] for the structure of each message.
$final boolean whether this method is called at the end of the current application

export() public method

public export ( )

getContextMessage() protected method

If [[includeContext]] is true, returns an empty string (so that context message in [[collect]] is not generated), expecting that context will be appended to every message in [[prepareMessage]].
protected getContextMessage ( ) : array
return array the context information

init() public method

This method will initialize the [[elasticsearch]] property to make sure it refers to a valid Elasticsearch connection.
public init ( )

prepareMessage() public method

Prepares a log message.
public prepareMessage ( array $message ) : string
$message array The log message to be formatted.
return string

Property Details

$_contextMessage protected_oe property

Context message cache (can be used multiple times if context is appended to every message)
protected $_contextMessage

$cacheContext public_oe property

If true, context message will cached once it's been created. Makes sense to use with [[includeContext]].
public $cacheContext

$db public_oe property

the elasticsearch connection object or the application component ID of the elasticsearch connection.
public $db

$includeContext public_oe property

If true, context will be included in every message. This is convenient if you log application errors and analyze them with tools like Kibana.
public $includeContext

$index public_oe property

Elasticsearch index name.
public $index

$logContext public_oe property

If true, context will be logged as a separate message after all other messages.
public $logContext

$options public_oe property

URL options.
public array $options
return array

$type public_oe property

Elasticsearch type name.
public $type