Add LoggerAwareInterface to ScopingHttpClient and TraceableHttpClient
This commit is contained in:
parent
1443b43e1b
commit
1137bdc3f7
@ -1,6 +1,11 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
5.1.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* added `LoggerAwareInterface` to `ScopingHttpClient` and `TraceableHttpClient`
|
||||||
|
|
||||||
4.4.0
|
4.4.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpClient;
|
namespace Symfony\Component\HttpClient;
|
||||||
|
|
||||||
|
use Psr\Log\LoggerAwareInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpClient\Exception\InvalidArgumentException;
|
use Symfony\Component\HttpClient\Exception\InvalidArgumentException;
|
||||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||||
@ -22,7 +24,7 @@ use Symfony\Contracts\Service\ResetInterface;
|
|||||||
*
|
*
|
||||||
* @author Anthony Martin <anthony.martin@sensiolabs.com>
|
* @author Anthony Martin <anthony.martin@sensiolabs.com>
|
||||||
*/
|
*/
|
||||||
class ScopingHttpClient implements HttpClientInterface, ResetInterface
|
class ScopingHttpClient implements HttpClientInterface, ResetInterface, LoggerAwareInterface
|
||||||
{
|
{
|
||||||
use HttpClientTrait;
|
use HttpClientTrait;
|
||||||
|
|
||||||
@ -98,4 +100,14 @@ class ScopingHttpClient implements HttpClientInterface, ResetInterface
|
|||||||
$this->client->reset();
|
$this->client->reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function setLogger(LoggerInterface $logger): void
|
||||||
|
{
|
||||||
|
if ($this->client instanceof LoggerAwareInterface) {
|
||||||
|
$this->client->setLogger($logger);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpClient;
|
namespace Symfony\Component\HttpClient;
|
||||||
|
|
||||||
|
use Psr\Log\LoggerAwareInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||||
use Symfony\Contracts\HttpClient\ResponseStreamInterface;
|
use Symfony\Contracts\HttpClient\ResponseStreamInterface;
|
||||||
@ -19,7 +21,7 @@ use Symfony\Contracts\Service\ResetInterface;
|
|||||||
/**
|
/**
|
||||||
* @author Jérémy Romey <jeremy@free-agent.fr>
|
* @author Jérémy Romey <jeremy@free-agent.fr>
|
||||||
*/
|
*/
|
||||||
final class TraceableHttpClient implements HttpClientInterface, ResetInterface
|
final class TraceableHttpClient implements HttpClientInterface, ResetInterface, LoggerAwareInterface
|
||||||
{
|
{
|
||||||
private $client;
|
private $client;
|
||||||
private $tracedRequests = [];
|
private $tracedRequests = [];
|
||||||
@ -75,4 +77,14 @@ final class TraceableHttpClient implements HttpClientInterface, ResetInterface
|
|||||||
|
|
||||||
$this->tracedRequests = [];
|
$this->tracedRequests = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function setLogger(LoggerInterface $logger): void
|
||||||
|
{
|
||||||
|
if ($this->client instanceof LoggerAwareInterface) {
|
||||||
|
$this->client->setLogger($logger);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user