Method: NetObserver::Logger#update

Defined in:
lib/net_observer/logger.rb

#update(type, request, body, connection) ⇒ Object

methods to receive information about connection. Needed to allow itself to register agains Base



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/net_observer/logger.rb', line 20

def update(type, request, body, connection)
  case type
  when :response
    method = request.kind_of?(Net::HTTPSuccess) ? :info : :warn
    @logger.send method, "get response: #{request.inspect} with body #{body}"
  when :request
    port = ""
    port = ":#{connection.port}" if (connection.port.to_i != (connection.use_ssl? ? 443 : 80))
    url = "#{connection.use_ssl? ? "https" : "http"}://#{connection.address}#{port}"
    @logger.info "get request for url #{url}#{request.path} with method: #{request.method} with body #{request.body || body}"
  end
end