Skip to content

Commit

Permalink
feature #54806 [HttpClient]  deprecate setLogger() methods of decorat…
Browse files Browse the repository at this point in the history
…ing clients (xabbuh)

This PR was merged into the 7.1 branch.

Discussion
----------

[HttpClient]  deprecate setLogger() methods of decorating clients

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | no
| Deprecations? | yes
| Issues        | Fix #54674 (review)
| License       | MIT

Commits
-------

9d95152 deprecate setLogger() methods of decorating clients
  • Loading branch information
fabpot committed May 2, 2024
2 parents 44461bf + 9d95152 commit 96d664e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions UPGRADE-7.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Components
* [ExpressionLanguage](#ExpressionLanguage)
* [Form](#Form)
* [Intl](#Intl)
* [HttpClient](#HttpClient)
* [PropertyInfo](#PropertyInfo)
* [Translation](#Translation)
* [Workflow](#Workflow)
Expand Down Expand Up @@ -72,6 +73,11 @@ FrameworkBundle
* Deprecate the `router.cache_dir` config option, the Router will always use the `kernel.build_dir` parameter
* Reset env vars when resetting the container

HttpClient
----------

* Deprecate the `setLogger()` methods of the `NoPrivateNetworkHttpClient`, `TraceableHttpClient` and `ScopingHttpClient` classes, configure the logger of the wrapped clients directly instead

Intl
----

Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/HttpClient/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CHANGELOG
* Allow mocking `start_time` info in `MockResponse`
* Add `MockResponse::fromFile()` and `JsonMockResponse::fromFile()` methods to help using fixtures files
* Add `ThrottlingHttpClient` to enable limiting the number of requests within a certain period
* Deprecate the `setLogger()` methods of the `NoPrivateNetworkHttpClient`, `TraceableHttpClient` and `ScopingHttpClient` classes, configure the logger of the wrapped clients directly instead

7.0
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,13 @@ public function stream(ResponseInterface|iterable $responses, ?float $timeout =
return $this->client->stream($responses, $timeout);
}

/**
* @deprecated since Symfony 7.1, configure the logger on the wrapper HTTP client directly instead
*/
public function setLogger(LoggerInterface $logger): void
{
trigger_deprecation('symfony/http-client', '7.1', 'Configure the logger on the wrapper HTTP client directly instead.');

if ($this->client instanceof LoggerAwareInterface) {
$this->client->setLogger($logger);
}
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/HttpClient/ScopingHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,13 @@ public function reset(): void
}
}

/**
* @deprecated since Symfony 7.1, configure the logger on the wrapper HTTP client directly instead
*/
public function setLogger(LoggerInterface $logger): void
{
trigger_deprecation('symfony/http-client', '7.1', 'Configure the logger on the wrapper HTTP client directly instead.');

if ($this->client instanceof LoggerAwareInterface) {
$this->client->setLogger($logger);
}
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/HttpClient/TraceableHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,13 @@ public function reset(): void
$this->tracedRequests->exchangeArray([]);
}

/**
* @deprecated since Symfony 7.1, configure the logger on the wrapper HTTP client directly instead
*/
public function setLogger(LoggerInterface $logger): void
{
trigger_deprecation('symfony/http-client', '7.1', 'Configure the logger on the wrapper HTTP client directly instead.');

if ($this->client instanceof LoggerAwareInterface) {
$this->client->setLogger($logger);
}
Expand Down

0 comments on commit 96d664e

Please sign in to comment.