Issue #3272447 by alexpott, Spokje, catch, xjm: Update to PSR/log v3

merge-requests/2367/head
catch 2022-06-10 09:43:20 +01:00
parent f35400e835
commit aac42cfeaf
10 changed files with 26 additions and 26 deletions

18
composer.lock generated
View File

@ -441,7 +441,7 @@
"dist": { "dist": {
"type": "path", "type": "path",
"url": "core", "url": "core",
"reference": "78d71b79ee40fcc2305472ed336bddcb03aacafc" "reference": "dc9d28de148cebd49d2c7cf3650fd836ed430a77"
}, },
"require": { "require": {
"asm89/stack-cors": "^2.0.2", "asm89/stack-cors": "^2.0.2",
@ -466,7 +466,7 @@
"masterminds/html5": "^2.7", "masterminds/html5": "^2.7",
"pear/archive_tar": "^1.4.14", "pear/archive_tar": "^1.4.14",
"php": ">=8.1.0", "php": ">=8.1.0",
"psr/log": "^2.0", "psr/log": "^3.0",
"symfony/console": "^6.1", "symfony/console": "^6.1",
"symfony/dependency-injection": "^6.1", "symfony/dependency-injection": "^6.1",
"symfony/event-dispatcher": "^6.1", "symfony/event-dispatcher": "^6.1",
@ -1756,16 +1756,16 @@
}, },
{ {
"name": "psr/log", "name": "psr/log",
"version": "2.0.0", "version": "3.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/log.git", "url": "https://github.com/php-fig/log.git",
"reference": "ef29f6d262798707a9edd554e2b82517ef3a9376" "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/ef29f6d262798707a9edd554e2b82517ef3a9376", "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001",
"reference": "ef29f6d262798707a9edd554e2b82517ef3a9376", "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1774,7 +1774,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.0.x-dev" "dev-master": "3.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -1800,9 +1800,9 @@
"psr-3" "psr-3"
], ],
"support": { "support": {
"source": "https://github.com/php-fig/log/tree/2.0.0" "source": "https://github.com/php-fig/log/tree/3.0.0"
}, },
"time": "2021-07-14T16:41:46+00:00" "time": "2021-07-14T16:46:02+00:00"
}, },
{ {
"name": "ralouphie/getallheaders", "name": "ralouphie/getallheaders",

View File

@ -27,7 +27,7 @@
"psr/http-client": "1.0.1", "psr/http-client": "1.0.1",
"psr/http-factory": "1.0.1", "psr/http-factory": "1.0.1",
"psr/http-message": "1.0.1", "psr/http-message": "1.0.1",
"psr/log": "2.0.0", "psr/log": "3.0.0",
"ralouphie/getallheaders": "3.0.3", "ralouphie/getallheaders": "3.0.3",
"symfony/console": "v6.1.1", "symfony/console": "v6.1.1",
"symfony/dependency-injection": "v6.1.0", "symfony/dependency-injection": "v6.1.0",

View File

@ -41,7 +41,7 @@
"composer/semver": "^3.3", "composer/semver": "^3.3",
"asm89/stack-cors": "^2.0.2", "asm89/stack-cors": "^2.0.2",
"pear/archive_tar": "^1.4.14", "pear/archive_tar": "^1.4.14",
"psr/log": "^2.0" "psr/log": "^3.0"
}, },
"conflict": { "conflict": {
"drush/drush": "<8.1.10" "drush/drush": "<8.1.10"

View File

@ -91,7 +91,7 @@ class LoggerChannel implements LoggerChannelInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function log($level, $message, array $context = []) { public function log($level, string|\Stringable $message, array $context = []): void {
if ($this->callDepth == self::MAX_CALL_DEPTH) { if ($this->callDepth == self::MAX_CALL_DEPTH) {
return; return;
} }

View File

@ -17,62 +17,62 @@ trait RfcLoggerTrait {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function emergency($message, array $context = []) { public function emergency(string|\Stringable $message, array $context = []): void {
$this->log(RfcLogLevel::EMERGENCY, $message, $context); $this->log(RfcLogLevel::EMERGENCY, $message, $context);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function alert($message, array $context = []) { public function alert(string|\Stringable $message, array $context = []): void {
$this->log(RfcLogLevel::ALERT, $message, $context); $this->log(RfcLogLevel::ALERT, $message, $context);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function critical($message, array $context = []) { public function critical(string|\Stringable $message, array $context = []): void {
$this->log(RfcLogLevel::CRITICAL, $message, $context); $this->log(RfcLogLevel::CRITICAL, $message, $context);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function error($message, array $context = []) { public function error(string|\Stringable $message, array $context = []): void {
$this->log(RfcLogLevel::ERROR, $message, $context); $this->log(RfcLogLevel::ERROR, $message, $context);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function warning($message, array $context = []) { public function warning(string|\Stringable $message, array $context = []): void {
$this->log(RfcLogLevel::WARNING, $message, $context); $this->log(RfcLogLevel::WARNING, $message, $context);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function notice($message, array $context = []) { public function notice(string|\Stringable $message, array $context = []): void {
$this->log(RfcLogLevel::NOTICE, $message, $context); $this->log(RfcLogLevel::NOTICE, $message, $context);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function info($message, array $context = []) { public function info(string|\Stringable $message, array $context = []): void {
$this->log(RfcLogLevel::INFO, $message, $context); $this->log(RfcLogLevel::INFO, $message, $context);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function debug($message, array $context = []) { public function debug(string|\Stringable $message, array $context = []): void {
$this->log(RfcLogLevel::DEBUG, $message, $context); $this->log(RfcLogLevel::DEBUG, $message, $context);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
abstract public function log($level, $message, array $context = []); abstract public function log($level, string|\Stringable $message, array $context = []): void;
} }

View File

@ -52,7 +52,7 @@ class DbLog implements LoggerInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function log($level, $message, array $context = []) { public function log($level, string|\Stringable $message, array $context = []): void {
// Remove backtrace and exception since they may contain an unserializable variable. // Remove backtrace and exception since they may contain an unserializable variable.
unset($context['backtrace'], $context['exception']); unset($context['backtrace'], $context['exception']);

View File

@ -60,7 +60,7 @@ class SysLog implements LoggerInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function log($level, $message, array $context = []) { public function log($level, string|\Stringable $message, array $context = []): void {
global $base_url; global $base_url;
$format = $this->config->get('format'); $format = $this->config->get('format');

View File

@ -16,7 +16,7 @@ class TestLog implements LoggerInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function log($level, $message, array $context = []) { public function log($level, string|\Stringable $message, array $context = []): void {
$trigger = [ $trigger = [
'%type' => 'Exception', '%type' => 'Exception',
'@message' => 'Deforestation', '@message' => 'Deforestation',

View File

@ -243,7 +243,7 @@ class UpdateFetcherTest extends UnitTestCase implements LoggerInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function log($level, $message, array $context = []) { public function log($level, string|\Stringable $message, array $context = []): void {
$this->logMessages[] = $context['@message']; $this->logMessages[] = $context['@message'];
} }

View File

@ -192,7 +192,7 @@ class NaughtyRecursiveLogger implements LoggerInterface {
$this->channel = $channel; $this->channel = $channel;
} }
public function log($level, $message, array $context = []) { public function log($level, string|\Stringable $message, array $context = []): void {
$this->channel->log(rand(0, 7), $message, $context); $this->channel->log(rand(0, 7), $message, $context);
} }