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

Logs 'base_uri' and query at Logger::CurlFormatter #458

Merged
merged 1 commit into from Jan 19, 2016

Conversation

dccunha
Copy link

@dccunha dccunha commented Jan 19, 2016

What?

This PR changes Logger::CurlFormatter and comprehends this:

  1. Adds URI's query parameters to the log output;
  2. Adds URI's full address (host + path) to the log output;

Why?

  1. When you use a query through an option the parameters aren't logged;
  2. When base_uri is set, only the path is being logged;
class DuckDuckGo
  include HTTParty
  base_uri 'duckduckgo.com'
  logger ::Logger.new("httparty.log"), :debug, :curl

  def search(options = {})
    self.class.get '/', options
  end
end

DuckDuckGo.new.search(query: {q: 'httparty'})

How it was?

D, [2016-01-19T17:32:25.802087 #26988] DEBUG -- : [HTTParty] [2016-01-19 17:32:25 -0200] > GET /
[HTTParty] [2016-01-19 17:32:25 -0200] > 
[HTTParty] [2016-01-19 17:32:25 -0200] > 
[HTTParty] [2016-01-19 17:32:25 -0200] < HTTP/1.1 301
[HTTParty] [2016-01-19 17:32:25 -0200] < Server: nginx
[HTTParty] [2016-01-19 17:32:25 -0200] < Date: Tue, 19 Jan 2016 19:32:25 GMT
[HTTParty] [2016-01-19 17:32:25 -0200] < Content-type: text/html
[HTTParty] [2016-01-19 17:32:25 -0200] < Content-length: 178
[HTTParty] [2016-01-19 17:32:25 -0200] < Connection: close
[HTTParty] [2016-01-19 17:32:25 -0200] < Location: https://duckduckgo.com/?q=httparty
[HTTParty] [2016-01-19 17:32:25 -0200] < Expires: Wed, 18 Jan 2017 19:32:25 GMT
[HTTParty] [2016-01-19 17:32:25 -0200] < Cache-control: max-age=31536000
[HTTParty] [2016-01-19 17:32:25 -0200] < 
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>

How it will be?

D, [2016-01-19T17:33:52.192973 #27484] DEBUG -- : [HTTParty] [2016-01-19 17:33:52 -0200] > GET http://duckduckgo.com/
[HTTParty] [2016-01-19 17:33:52 -0200] > Query: 
[HTTParty] [2016-01-19 17:33:52 -0200] > q: httparty
[HTTParty] [2016-01-19 17:33:52 -0200] > 
[HTTParty] [2016-01-19 17:33:52 -0200] < HTTP/1.1 301
[HTTParty] [2016-01-19 17:33:52 -0200] < Server: nginx
[HTTParty] [2016-01-19 17:33:52 -0200] < Date: Tue, 19 Jan 2016 19:33:52 GMT
[HTTParty] [2016-01-19 17:33:52 -0200] < Content-type: text/html
[HTTParty] [2016-01-19 17:33:52 -0200] < Content-length: 178
[HTTParty] [2016-01-19 17:33:52 -0200] < Connection: close
[HTTParty] [2016-01-19 17:33:52 -0200] < Location: https://duckduckgo.com/?q=httparty
[HTTParty] [2016-01-19 17:33:52 -0200] < Expires: Wed, 18 Jan 2017 19:33:52 GMT
[HTTParty] [2016-01-19 17:33:52 -0200] < Cache-control: max-age=31536000
[HTTParty] [2016-01-19 17:33:52 -0200] < 
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
[HTTParty] [2016-01-19 17:33:52 -0200] < 

jnunemaker pushed a commit that referenced this pull request Jan 19, 2016
Logs 'base_uri' and query at Logger::CurlFormatter
@jnunemaker jnunemaker merged commit 35b8ed3 into jnunemaker:master Jan 19, 2016
@dccunha
Copy link
Author

dccunha commented Jan 20, 2016

Don't know where is the best place to ask, but how is the release policy for new versions? I saw at README that I can bump version, but CONTRIBUTING say that I shouldn't.

@dccunha dccunha deleted the adds_query_to_curl_formatter branch January 20, 2016 12:12
@jnunemaker
Copy link
Owner

I do releases after a week or two or a few changes go in. In general, I try to avoid doing a release for each PR. If you want to use the code right now, you should be able to name the class something new and put it in your project and then tell httparty to use it.

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

Successfully merging this pull request may close these issues.

None yet

2 participants