Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HttpClient] Implemented LoggerAwareInterface in HttpClientInterface decorators #54668

Merged

Conversation

yann-eugone
Copy link
Contributor

@yann-eugone yann-eugone commented Apr 19, 2024

Implement Psr\Log\LoggerAwareInterface in Symfony\Component\HttpClient\UriTemplateHttpClient.

Q A
Branch? 7.1
Bug fix? no
New feature? no
Deprecations? no
Issues
License MIT

I was on a journey to enhance our logs on a project that highly depend on HttpClient.
I started to separate logs per feature, and I wanted to include HttpClient logs to the logger of the currently running the feature.

I figured out that most implementations of HttpClientInterface are implementing LoggerAwareInterface, so I decided to just call $client->setLogger(...) on my side.
And nothing changed.

Nothing changed because my logger is decorated by the UriTemplateHttpClient that is not implementing LoggerAwareInterface.
Althought UriTemplateHttpClient has no need of a logger, as a decorator it should be able to act like it, so the underlying client can be reached.
This is what is done for instance in Symfony\Component\HttpClient\TraceableHttpClient.

@carsonbot carsonbot added this to the 7.1 milestone Apr 19, 2024
@yann-eugone yann-eugone changed the title [HttpClient] Add LoggerAwareInterface to UriTemplateHttpClient [HttpClient] Implement LoggerAwareInterface in UriTemplateHttpClient Apr 19, 2024
@nicolas-grekas
Copy link
Member

Can you please do the same for all decorators? I see that others could need that change.

1 similar comment
@nicolas-grekas
Copy link
Member

Can you please do the same for all decorators? I see that others could need that change.

@yann-eugone
Copy link
Contributor Author

@nicolas-grekas sure, just did : 7f2fe9b

@yann-eugone yann-eugone changed the title [HttpClient] Implement LoggerAwareInterface in UriTemplateHttpClient [HttpClient] Implemented LoggerAwareInterface in HttpClientInterface decorators Apr 19, 2024
@nicolas-grekas nicolas-grekas force-pushed the logger-aware-uri-template-http-client branch from 7f2fe9b to c2a7b73 Compare April 19, 2024 07:14
@nicolas-grekas
Copy link
Member

Thank you @yann-eugone.

@nicolas-grekas nicolas-grekas merged commit 924e4d8 into symfony:7.1 Apr 19, 2024
8 of 10 checks passed
@yann-eugone
Copy link
Contributor Author

Happy to help 🙂

@fabpot
Copy link
Member

fabpot commented May 2, 2024

Reverted in #54674

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants