Class: NetObserver::Logger
- Inherits:
-
Object
- Object
- NetObserver::Logger
- Defined in:
- lib/net_observer/logger.rb
Overview
NetObserver::Logger.new Logger.new STDOUT
Instance Method Summary collapse
-
#initialize(logger) ⇒ Logger
constructor
@param(Logger) logger which recieve informations about communication.
-
#update(type, request, body, connection) ⇒ Object
methods to receive information about connection.
Constructor Details
Instance Method Details
#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 |