Skip to content

Commit

Permalink
Allow psr/log in version 2 and 3, like guzzlehttp/guzzle do it (#44)
Browse files Browse the repository at this point in the history
* Use guzzle psr7 messageinterface to string method, to be compatible with psr/log 2 and 3

* Allow psr/log version 2 and 3, too
  • Loading branch information
skimmerle authored Mar 22, 2022
1 parent 6faa479 commit 6849113
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"ext-json": "*",
"guzzlehttp/guzzle": "^6.1 || ^7.0.1",
"guzzlehttp/psr7": "^1.7 || ^2.0",
"psr/log": "^1.1"
"psr/log": "^1.1 || ^2.0 || ^3.0"
},
"require-dev": {
"phpstan/phpstan": "~0.12.32",
Expand Down
4 changes: 2 additions & 2 deletions src/Handler/StringHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private function logRequest(LoggerInterface $logger, RequestInterface $value, ar
return;
}

$str = \GuzzleHttp\Psr7\str($value);
$str = \GuzzleHttp\Psr7\Message::toString($value);

$level = $this->logLevelStrategy->getLevel($value, $options);
$logger->log($level, 'Guzzle HTTP request:' . "\n" . $str);
Expand All @@ -67,7 +67,7 @@ private function logResponse(LoggerInterface $logger, ResponseInterface $value,
return;
}

$str = \GuzzleHttp\Psr7\str($value);
$str = \GuzzleHttp\Psr7\Message::toString($value);

$level = $this->logLevelStrategy->getLevel($value, $options);
$logger->log($level, 'Guzzle HTTP response:' . "\n" . $str);
Expand Down

0 comments on commit 6849113

Please sign in to comment.