-
Notifications
You must be signed in to change notification settings - Fork 119
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
New step: Log request/response #249
Comments
# test/test_helper.exs
Req.default_options(...) then it's ok if it's a bit verbose. So another suggestion is to have: Req.new(
log_request: true | format,
log_response: true | format
) |
Hi there, this would be useful indeed. I used
An excerpt output is:
Implementation was straightforward ( Cheers. |
Another use case outside of testing that I'm particularly interested in is logging the request method, URL, response status, and most importantly, the time taken. Similar to tesla's Logger middleware:
I tried to write a req plugin for my own use, but had trouble getting the time measurement to work when a request is retried. |
I was considering this too for a plugin, and, since the request steps never run a second time (do not run for the retries), what can be done is inspect You could use a custom adapter that wraps Finch (or any other "real" adapter), times the request and store it/log it. |
Hi @thenrio I would love to get a hold of this code if you are able to share it :) I am trying to debug some http requests by comparing the request/response and seeing the raw request would be extremely helpful. |
@venkatd Something like that?
|
Thanks a lot! |
Wow this would be so incredibly useful, I've always want this kind of functionality in every http library, cool to see Req plan to have it. |
TBD the naming and output formatting but basically we want to dump the raw request and response for debugging. Something like this:
It's using logger so that users can enable this in tests but also set
@tag :capture_log
, i.e. see this only when the tests fail.HTTPie has interesting options for output formatting:
so we might look into something like that too. Or, we double-down on logger and expose variables to be used by formatting configuration:
"\n$time $metadata[$level] $message\n"
cc @reisub
The text was updated successfully, but these errors were encountered: