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\QueryLoggerPsr\Log\LoggerInterface
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\QueryLoggerPsr\Log\LoggerInterface $logger, Cake\ElasticSearch\Datasource\Connection $connection)
Constructor, set the QueryLogger instance
Parameters
-
Cake\Database\Log\QueryLoggerPsr\Log\LoggerInterface
$logger Instance of the QueryLogger
-
Cake\ElasticSearch\Datasource\Connection
$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(stringStringable $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
-
stringStringable
$message -
mixed[]
$context optional
Returns
void
critical() ¶ public
critical(stringStringable $message, mixed[] $context = []): void
Critical conditions.
Example: Application component unavailable, unexpected exception.
Parameters
-
stringStringable
$message -
mixed[]
$context optional
Returns
void
debug() ¶ public
debug(stringStringable $message, mixed[] $context = []): void
Detailed debug information.
Parameters
-
stringStringable
$message -
mixed[]
$context optional
Returns
void
emergency() ¶ public
emergency(stringStringable $message, mixed[] $context = []): void
System is unusable.
Parameters
-
stringStringable
$message -
mixed[]
$context optional
Returns
void
error() ¶ public
error(stringStringable $message, mixed[] $context = []): void
Runtime errors that do not require immediate action but should typically be logged and monitored.
Parameters
-
stringStringable
$message -
mixed[]
$context optional
Returns
void
getLogger() ¶ public
getLogger(): Cake\Database\Log\QueryLoggerPsr\Log\LoggerInterface
Return the current logger
Returns
Cake\Database\Log\QueryLoggerPsr\Log\LoggerInterface
info() ¶ public
info(stringStringable $message, mixed[] $context = []): void
Interesting events.
Example: User logs in, SQL logs.
Parameters
-
stringStringable
$message -
mixed[]
$context optional
Returns
void
log() ¶ public
log(mixed $level, Stringable|string $message, mixed[] $context = []): void
Format log messages from the Elastica client _log method
Parameters
-
mixed
$level The log level
-
Stringable|string
$message The log message
-
mixed[]
$context optional log context
Returns
void
notice() ¶ public
notice(stringStringable $message, mixed[] $context = []): void
Normal but significant events.
Parameters
-
stringStringable
$message -
mixed[]
$context optional
Returns
void
setLogger() ¶ public
setLogger(Cake\Database\Log\QueryLoggerPsr\Log\LoggerInterface $logger): $this
Set the current cake logger
Parameters
-
Cake\Database\Log\QueryLoggerPsr\Log\LoggerInterface
$logger Set logger instance to pass logging data to
Returns
$this
warning() ¶ public
warning(stringStringable $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
-
stringStringable
$message -
mixed[]
$context optional
Returns
void