-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpClient] Add LoggerAwareInterface to ScopingHttpClient and TraceableHttpClient #35273
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
Conversation
f66afc4
to
7348fb2
Compare
7348fb2
to
1137bdc
Compare
But one should be able to configure the decorated client before decorating it. I think not having this method encourages better instantiation steps. I get this can be helpful, but maybe here we'd prefer favoring better design? |
This doesn't work when injecting a scoped client from the framework configuration, as you are then stuck with the default logger and can't change it at runtime (E.G injecting a |
Thank you @pierredup. |
…ient and TraceableHttpClient (pierredup) This PR was merged into the 5.1-dev branch. Discussion ---------- [HttpClient] Add LoggerAwareInterface to ScopingHttpClient and TraceableHttpClient | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A This allows changing the logger when using `ScopingHttpClient` (and `TraceableHttpClient` during dev) Commits ------- 1137bdc Add LoggerAwareInterface to ScopingHttpClient and TraceableHttpClient
I think that if you need an HttpClient with a different logger in some place, you should then configure a separate HttpClient exactly for this use case. Services are lazy-loaded, so it does not matter how many clients you have anyway. Mutating services at Runtime is a bad practice — it leads to unpredictable behavior in services that reuse them. It's really sad that Also decorators should not imply that inner services have some other interfaces and downcast them to figure that out. What if -1 inner client is not |
This allows changing the logger when using
ScopingHttpClient
(andTraceableHttpClient
during dev)