class LoggingHttpClient
Public Class Methods
new(base_uri, path)
click to toggle source
Calls superclass method
# File lib/logging_http_client.rb, line 6 def initialize(base_uri, path) super(base_uri) @logger = Logger.new(path) end
Public Instance Methods
execute(request)
click to toggle source
Calls superclass method
# File lib/logging_http_client.rb, line 11 def execute(request) original_open = client.open_timeout original_read = client.read_timeout start_time = Time.now.utc.round(10) @logger.info "start %s %s" % [request.method, request.path] if request.path.start_with?("/organizations") # Contrived example to show how client settings can be adjusted client.open_timeout = 60 client.read_timeout = 60 end begin super ensure client.open_timeout = original_open client.read_timeout = original_read end_time = Time.now.utc.round(10) duration = ((end_time - start_time)*1000).round(0) @logger.info "complete %s %s %s ms" % [request.method, request.path, duration] end end