-
Notifications
You must be signed in to change notification settings - Fork 7
Deduplicate request logs, couple request<>response by UID #19
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, looks good to me. can you please look at the failing tests? i think the tests have assertions on how the logger is called (which makes sense, as this is the whole purpose of this plugin).
i think i see this as a new minor version, as it adds something significant.
please add a note to the changelog about the change. i think it would be correct to mention there to configure a logger with the fingerscrossed behaviour (don't need detailed instructions, just mention it so people can find the doc if they are not familiar). because if you only log something more severe than info, this new behaviour will no longer let you see the request that led to an error.
we should also update https://github.com/php-http/documentation/blob/master/plugins/logger.rst to have the example use a fingers crossed logger and a note why we use that instead of a straight logger. |
@dbu done. I'll let you update docs, i dont see how "fingerscrossed" is relevant. We always log certain channels, that are used dedicated for http traffic. |
$milliseconds = (int) round((hrtime(true) / 1E6 - $start)); | ||
if ($exception instanceof Exception\HttpException) { | ||
$this->logger->error( | ||
sprintf("Error:\n%s\nwith response:\n%s\n\nwhen sending request:\n%s", $exception->getMessage(), $this->formatter->formatResponse($exception->getResponse()), $this->formatter->formatRequest($request)), | ||
sprintf("Error:\n%s\nwith response:\n%s", $exception->getMessage(), $this->formatter->formatResponse($exception->getResponse())), | ||
[ | ||
'request' => $request, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you still specify the request in the context. is that on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i left other context entries untouched.
this is for #16 to solve, but in CLI it works well:
16:07:07 INFO [app] Received response:
HTTP/1.1 200 OK
[
"request" => GuzzleHttp\Psr7\Request {
-method: "GET"
i wouldnt mind if these are dropped though :) if these objects become stringable/serializable one day, it starts leaking into prod logs.
Arguably, even in dev env it's just noise.
thanks a lot! i addjusted the changelog and squashed commits, then merged locally. |
i wait with tagging until #16 is clarified and maybe php-http/message#146 as well |
Given
For me this works OK, and could go as a patch release. But any next version works for us 👍