Skip to content

Commit 7348fb2

Browse files
committed
Add LoggerAwareInterface to ScopingHttpClient and TraceableHttpClient
1 parent 1443b43 commit 7348fb2

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/Symfony/Component/HttpClient/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
5.1.0
5+
-----
6+
7+
* added `LoggerAwareInterface` to `ScopingHttpClient` and `TraceableHttpClient`
8+
49
4.4.0
510
-----
611

src/Symfony/Component/HttpClient/ScopingHttpClient.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\HttpClient;
1313

14+
use Psr\Log\LoggerAwareInterface;
15+
use Psr\Log\LoggerInterface;
1416
use Symfony\Component\HttpClient\Exception\InvalidArgumentException;
1517
use Symfony\Contracts\HttpClient\HttpClientInterface;
1618
use Symfony\Contracts\HttpClient\ResponseInterface;
@@ -22,7 +24,7 @@
2224
*
2325
* @author Anthony Martin <anthony.martin@sensiolabs.com>
2426
*/
25-
class ScopingHttpClient implements HttpClientInterface, ResetInterface
27+
class ScopingHttpClient implements HttpClientInterface, ResetInterface, LoggerAwareInterface
2628
{
2729
use HttpClientTrait;
2830

@@ -98,4 +100,14 @@ public function reset()
98100
$this->client->reset();
99101
}
100102
}
103+
104+
/**
105+
* {@inheritdoc}
106+
*/
107+
public function setLogger(LoggerInterface $logger)
108+
{
109+
if ($this->client instanceof LoggerAwareInterface) {
110+
$this->client->setLogger($logger);
111+
}
112+
}
101113
}

src/Symfony/Component/HttpClient/TraceableHttpClient.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\HttpClient;
1313

14+
use Psr\Log\LoggerAwareInterface;
15+
use Psr\Log\LoggerInterface;
1416
use Symfony\Contracts\HttpClient\HttpClientInterface;
1517
use Symfony\Contracts\HttpClient\ResponseInterface;
1618
use Symfony\Contracts\HttpClient\ResponseStreamInterface;
@@ -19,7 +21,7 @@
1921
/**
2022
* @author Jérémy Romey <jeremy@free-agent.fr>
2123
*/
22-
final class TraceableHttpClient implements HttpClientInterface, ResetInterface
24+
final class TraceableHttpClient implements HttpClientInterface, ResetInterface, LoggerAwareInterface
2325
{
2426
private $client;
2527
private $tracedRequests = [];
@@ -75,4 +77,14 @@ public function reset()
7577

7678
$this->tracedRequests = [];
7779
}
80+
81+
/**
82+
* {@inheritdoc}
83+
*/
84+
public function setLogger(LoggerInterface $logger)
85+
{
86+
if ($this->client instanceof LoggerAwareInterface) {
87+
$this->client->setLogger($logger);
88+
}
89+
}
7890
}

0 commit comments

Comments
 (0)