Skip to content

Commit

Permalink
Allow psr/log v3
Browse files Browse the repository at this point in the history
  • Loading branch information
ruudk committed Jan 21, 2022
1 parent f87f93f commit a817799
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 46 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -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": "*",
Expand Down
2 changes: 1 addition & 1 deletion src/Elasticsearch/Common/EmptyLogger.php
Expand Up @@ -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;
}
Expand Down
47 changes: 3 additions & 44 deletions tests/Elasticsearch/Tests/ClientBuilder/ArrayLogger.php
Expand Up @@ -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));
}
Expand Down

0 comments on commit a817799

Please sign in to comment.