Skip to content

Instantly share code, notes, and snippets.

@mrk21
Created September 25, 2019 06:00
Show Gist options
  • Save mrk21/5cf6e6a21c20109adb9e0119095819d2 to your computer and use it in GitHub Desktop.
Save mrk21/5cf6e6a21c20109adb9e0119095819d2 to your computer and use it in GitHub Desktop.
How to output logs for Net::HTTP
require 'net/http'
# @see https://qiita.com/mechamogera/items/d9ea1cf043e976641a23#rails%E3%81%A7%E7%A2%BA%E8%AA%8D%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95
class Net::HTTP
alias :create :initialize
def initialize(*args)
logger = ActiveSupport::Logger.new(STDOUT)
create(*args)
self.set_debug_output logger
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment