Created
May 22, 2014 15:52
-
-
Save rafbm/5444eab341ffd60c2146 to your computer and use it in GitHub Desktop.
Net::HTTP provides instance-level debugging. Here’s how to toggle it globally with `Net::HTTP.debug=`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/net_http_debug.rb | |
if Rails.env.development? | |
require 'net/http' | |
Net::HTTP.class_eval do | |
class << self | |
attr_accessor :debug | |
end | |
prepend Module.new { | |
def initialize(*args) | |
super | |
set_debug_output(STDERR) if self.class.debug | |
end | |
} | |
end | |
Net::HTTP.debug = true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment