Thursday, August 6, 2015

Turn on Net::HTTP Instance Debugging Externally

Here's a way to turn on HTTP::Net debug, if you don't want to patch something that is using it or use some other method to debug:

module Net
  class HTTP
    alias_method :debug_renamed_initialize, :initialize
    def initialize(*args, &block)
      http = debug_renamed_initialize(*args, &block)
      self.set_debug_output $stderr
      http
    end
  end
end

No comments: