diff --git a/src/Symfony/Component/HttpClient/CachingHttpClient.php b/src/Symfony/Component/HttpClient/CachingHttpClient.php index fd6a18c3cc1b1..f576a14a00a0b 100644 --- a/src/Symfony/Component/HttpClient/CachingHttpClient.php +++ b/src/Symfony/Component/HttpClient/CachingHttpClient.php @@ -11,6 +11,8 @@ namespace Symfony\Component\HttpClient; +use Psr\Log\LoggerAwareInterface; +use Psr\Log\LoggerInterface; use Symfony\Component\HttpClient\Response\MockResponse; use Symfony\Component\HttpClient\Response\ResponseStream; use Symfony\Component\HttpFoundation\Request; @@ -31,7 +33,7 @@ * * @author Nicolas Grekas
*/
-class CachingHttpClient implements HttpClientInterface, ResetInterface
+class CachingHttpClient implements HttpClientInterface, LoggerAwareInterface, ResetInterface
{
use HttpClientTrait;
@@ -142,4 +144,11 @@ public function reset(): void
$this->client->reset();
}
}
+
+ public function setLogger(LoggerInterface $logger): void
+ {
+ if ($this->client instanceof LoggerAwareInterface) {
+ $this->client->setLogger($logger);
+ }
+ }
}
diff --git a/src/Symfony/Component/HttpClient/EventSourceHttpClient.php b/src/Symfony/Component/HttpClient/EventSourceHttpClient.php
index 4e551ac0409f6..7bb43532cbbc0 100644
--- a/src/Symfony/Component/HttpClient/EventSourceHttpClient.php
+++ b/src/Symfony/Component/HttpClient/EventSourceHttpClient.php
@@ -11,6 +11,8 @@
namespace Symfony\Component\HttpClient;
+use Psr\Log\LoggerAwareInterface;
+use Psr\Log\LoggerInterface;
use Symfony\Component\HttpClient\Chunk\ServerSentEvent;
use Symfony\Component\HttpClient\Exception\EventSourceException;
use Symfony\Component\HttpClient\Response\AsyncContext;
@@ -25,7 +27,7 @@
* @author Antoine Bluchet
*/
-final class EventSourceHttpClient implements HttpClientInterface, ResetInterface
+final class EventSourceHttpClient implements HttpClientInterface, LoggerAwareInterface, ResetInterface
{
use AsyncDecoratorTrait, HttpClientTrait {
AsyncDecoratorTrait::withOptions insteadof HttpClientTrait;
@@ -156,4 +158,11 @@ public function request(string $method, string $url, array $options = []): Respo
}
});
}
+
+ public function setLogger(LoggerInterface $logger): void
+ {
+ if ($this->client instanceof LoggerAwareInterface) {
+ $this->client->setLogger($logger);
+ }
+ }
}
diff --git a/src/Symfony/Component/HttpClient/RetryableHttpClient.php b/src/Symfony/Component/HttpClient/RetryableHttpClient.php
index d3b779420ffa9..412dfa262ab77 100644
--- a/src/Symfony/Component/HttpClient/RetryableHttpClient.php
+++ b/src/Symfony/Component/HttpClient/RetryableHttpClient.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\HttpClient;
+use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpClient\Response\AsyncContext;
use Symfony\Component\HttpClient\Response\AsyncResponse;
@@ -27,7 +28,7 @@
*
* @author Jérémy Derussé