diff --git a/composer.json b/composer.json index 8122c5c20..c49a8113f 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php": "^7.3 || ^8.0", "ext-json": ">=1.3.7", "ezimuel/ringphp": "^1.1.2", - "psr/log": "^1|^2" + "psr/log": "^1|^2|^3" }, "require-dev": { "ext-yaml": "*", diff --git a/src/Elasticsearch/Common/EmptyLogger.php b/src/Elasticsearch/Common/EmptyLogger.php index 938a4e51b..2acde2944 100644 --- a/src/Elasticsearch/Common/EmptyLogger.php +++ b/src/Elasticsearch/Common/EmptyLogger.php @@ -32,7 +32,7 @@ class EmptyLogger extends AbstractLogger implements LoggerInterface /** * {@inheritDoc} */ - public function log($level, $message, array $context = []) + public function log($level, $message, array $context = []): void { return; } diff --git a/tests/Elasticsearch/Tests/ClientBuilder/ArrayLogger.php b/tests/Elasticsearch/Tests/ClientBuilder/ArrayLogger.php index bd31a9177..91652f3e0 100644 --- a/tests/Elasticsearch/Tests/ClientBuilder/ArrayLogger.php +++ b/tests/Elasticsearch/Tests/ClientBuilder/ArrayLogger.php @@ -17,57 +17,16 @@ namespace Elasticsearch\Tests\ClientBuilder; -use Psr\Log\LoggerInterface; -use Psr\Log\LogLevel; +use Psr\Log\AbstractLogger; -class ArrayLogger implements LoggerInterface +class ArrayLogger extends AbstractLogger { /** * @var mixed[] */ public $output = []; - public function emergency($message, array $context = array()) - { - $this->log(LogLevel::EMERGENCY, $message, $context); - } - - public function alert($message, array $context = array()) - { - $this->log(LogLevel::ALERT, $message, $context); - } - - public function critical($message, array $context = array()) - { - $this->log(LogLevel::CRITICAL, $message, $context); - } - - public function error($message, array $context = array()) - { - $this->log(LogLevel::ERROR, $message, $context); - } - - public function warning($message, array $context = array()) - { - $this->log(LogLevel::WARNING, $message, $context); - } - - public function notice($message, array $context = array()) - { - $this->log(LogLevel::NOTICE, $message, $context); - } - - public function info($message, array $context = array()) - { - $this->log(LogLevel::INFO, $message, $context); - } - - public function debug($message, array $context = array()) - { - $this->log(LogLevel::DEBUG, $message, $context); - } - - public function log($level, $message, array $context = array()) + public function log($level, $message, array $context = array()): void { $this->output[] = sprintf("%s: %s %s", $level, $message, json_encode($context)); }