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

Display requests and responses? #220

Closed
JohnSmall opened this issue Dec 6, 2016 · 3 comments
Closed

Display requests and responses? #220

JohnSmall opened this issue Dec 6, 2016 · 3 comments

Comments

@JohnSmall
Copy link

Any idea how I can get it to display the full request and response?

It's doing something wrong when interacting with an API I don't have control over and can't see what's coming through. So I need to see what's being sent.

@natemacinnes
Copy link
Contributor

Add this to your base class:

   Base.connection do | connection |
        connection.use Faraday::Response::Logger
    end 

The above will output the raw request and response text to stdout.

@JohnSmall
Copy link
Author

Yes, I'd already tried that. It displays the url for the POST/PATCH, but not the body, so it's a bit useless.

However I got around the problem by following the guidelines on how to get VCR to work in #171. So I just had to look at the yml files created by VCR to see what was being sent and that solved my problem. So I'll close this,

@natemacinnes
Copy link
Contributor

natemacinnes commented Dec 9, 2016

Oh, yeah forgot about that, I ended up using a gem that included bodies:

Base.connection do | connection |
    connection.use DetailedLogger
end 

and more recently found out that Faraday includes it with a little manipulation:

Faraday.new do |faraday|
    faraday.response :logger, ::Logger.new(STDOUT), bodies: true
end

ref: faraday pull request

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

No branches or pull requests

2 participants