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

Added initial logging support. #243

Merged
merged 6 commits into from
Oct 10, 2013
Merged

Conversation

lucasuyezu
Copy link
Contributor

The idea is that you can log your requests using either the include syntax and the direct HTTParty class.

Using include:

class GoogleFetcher
  include HTTParty
  logger Rails.logger
end

Using HTTParty:

HTTParty.get "http://google.com", :logger => Rails.logger

I have included two log styles, one that resembles apache's access log and another that resembles curl, which can be used by passing :log_format => :curl.

You can also control which method is called on logger by passing :log_level => :debug for example.

Please let me know if the code does not adhere to the project's standards or if I need to change anything.

Opinions and criticism are welcome.

@jnunemaker
Copy link
Owner

Travis CI is showing a test failure. Can you fix that up?

@darkside
Copy link

darkside commented Oct 9, 2013

👍

1 similar comment
@herbert
Copy link

herbert commented Oct 9, 2013

👍

@PotHix
Copy link

PotHix commented Oct 9, 2013

👍

Really useful! :D

@elvisnm
Copy link

elvisnm commented Oct 9, 2013

👍

1 similar comment
@wilerson
Copy link

wilerson commented Oct 9, 2013

👍

end

def format(request, response)
@current_time ||= Time.new.strftime("%Y-%m-%d %H:%M:%S.%L %z")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this make it always use the same time?

@jnunemaker
Copy link
Owner

Getting really close. Thanks for all the work!

@lucasuyezu
Copy link
Contributor Author

The memoization was there because it was hard to test using Time.new. But since I am testing using regexp, I don't need it anymore.

Also, I created the raw_body method as requested.

@jnunemaker jnunemaker merged commit 45c9b55 into jnunemaker:master Oct 10, 2013
@jnunemaker
Copy link
Owner

Merged. Thanks.

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.

9 participants