Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow psr/log 3 #1190

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
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"
franmomu marked this conversation as resolved.
Show resolved Hide resolved
},
"require-dev": {
"ext-yaml": "*",
Expand Down
2 changes: 1 addition & 1 deletion src/Elasticsearch/Common/EmptyLogger.php
Original file line number Diff line number Diff line change
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that this is BC break, but given the name of the class, I guess it is not meant to be extended.

{
return;
}
Expand Down
47 changes: 3 additions & 44 deletions tests/Elasticsearch/Tests/ClientBuilder/ArrayLogger.php
Original file line number Diff line number Diff line change
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