Class ElasticLogger
Adapter to convert elastic logs to QueryLogger readable content
Property Summary
-
$_connection protected
Cake\ElasticSearch\Datasource\Connection
Holds the connection instance
-
$_logger protected
Cake\Database\Log\QueryLogger|Cake\Log\Engine\BaseLog
Holds the logger instance
Method Summary
-
__construct() public
Constructor, set the QueryLogger instance
-
_log() protected
Format log messages from the Elastica client and pass them to the cake defined logger instance
-
alert() public
Action must be taken immediately.
-
critical() public
Critical conditions.
-
debug() public
Detailed debug information.
-
emergency() public
System is unusable.
-
error() public
Runtime errors that do not require immediate action but should typically be logged and monitored.
-
getLogger() public
Return the current logger
-
info() public
Interesting events.
-
log() public
Format log messages from the Elastica client _log method
-
notice() public
Normal but significant events.
-
setLogger() public
Set the current cake logger
-
warning() public
Exceptional occurrences that are not errors.
Method Detail
__construct() ¶ public
__construct(Cake\Database\Log\QueryLogger|Cake\Log\Engine\BaseLog $logger, Cake\Datasource\ConnectionInterface $connection)
Constructor, set the QueryLogger instance
Parameters
-
Cake\Database\Log\QueryLogger|Cake\Log\Engine\BaseLog
$logger Instance of the QueryLogger
-
Cake\Datasource\ConnectionInterface
$connection Current connection instance
_log() ¶ protected
_log(string $level, string $message, array $context = []): void
Format log messages from the Elastica client and pass them to the cake defined logger instance
Elastica's log parameters
error: message: "Elastica Request Failure" context: [ exception, request, retry ] debug (request): message: "Elastica Request" context: [ request, response, responseStatus, query ] debug (fallback?): message: "Elastica Request" context: [ message, query ]
Parameters
-
string
$level The log level
-
string
$message The log message
-
array
$context optional log context
Returns
void
alert() ¶ public
alert(string|Stringable $message, mixed[] $context = []): void
Action must be taken immediately.
Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.
Parameters
-
string|Stringable
$message -
mixed[]
$context optional
Returns
void
critical() ¶ public
critical(string|Stringable $message, mixed[] $context = []): void
Critical conditions.
Example: Application component unavailable, unexpected exception.
Parameters
-
string|Stringable
$message -
mixed[]
$context optional
Returns
void
debug() ¶ public
debug(string|Stringable $message, mixed[] $context = []): void
Detailed debug information.
Parameters
-
string|Stringable
$message -
mixed[]
$context optional
Returns
void
emergency() ¶ public
emergency(string|Stringable $message, mixed[] $context = []): void
System is unusable.
Parameters
-
string|Stringable
$message -
mixed[]
$context optional
Returns
void
error() ¶ public
error(string|Stringable $message, mixed[] $context = []): void
Runtime errors that do not require immediate action but should typically be logged and monitored.
Parameters
-
string|Stringable
$message -
mixed[]
$context optional
Returns
void
getLogger() ¶ public
getLogger(): Cake\Database\Log\QueryLogger|Cake\Log\Engine\BaseLog|Psr\Log\NullLogger
Return the current logger
Returns
Cake\Database\Log\QueryLogger|Cake\Log\Engine\BaseLog|Psr\Log\NullLogger
info() ¶ public
info(string|Stringable $message, mixed[] $context = []): void
Interesting events.
Example: User logs in, SQL logs.
Parameters
-
string|Stringable
$message -
mixed[]
$context optional
Returns
void
log() ¶ public
log(mixed $level, string $message, mixed[] $context = []): void
Format log messages from the Elastica client _log method
Parameters
-
mixed
$level The log level
-
string
$message The log message
-
mixed[]
$context optional log context
Returns
void
notice() ¶ public
notice(string|Stringable $message, mixed[] $context = []): void
Normal but significant events.
Parameters
-
string|Stringable
$message -
mixed[]
$context optional
Returns
void
setLogger() ¶ public
setLogger(Cake\Database\Log\QueryLogger|Cake\Log\Engine\BaseLog $logger): $this
Set the current cake logger
Parameters
-
Cake\Database\Log\QueryLogger|Cake\Log\Engine\BaseLog
$logger Set logger instance to pass logging data to
Returns
$this
warning() ¶ public
warning(string|Stringable $message, mixed[] $context = []): void
Exceptional occurrences that are not errors.
Example: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.
Parameters
-
string|Stringable
$message -
mixed[]
$context optional
Returns
void