Sha256: 1c7cd10e8898550253e4d0bd2612a4e0cf0328eb4d59b6079985a575a5039009
Contents?: true
Size: 1.79 KB
Versions: 4
Compression:
Stored size: 1.79 KB
Contents
if defined?(Excon) module Excon class Socket alias_method :orig_connect, :connect def connect host = @data[:proxy] ? @data[:proxy][:host] : @data[:host] port = @data[:proxy] ? @data[:proxy][:port] : @data[:port] HttpLog.log_connection(host, port) orig_connect end end class Connection def _httplog_url(datum) "#{datum[:scheme]}://#{datum[:host]}:#{datum[:port]}#{datum[:path]}#{datum[:query]}" end alias_method :orig_request, :request def request(params, &block) result = nil bm = Benchmark.realtime do result = orig_request(params, &block) end datum = @data.merge(params) datum[:headers] = @data[:headers].merge(datum[:headers] || {}) url = _httplog_url(datum) if HttpLog.url_approved?(url) HttpLog.log_compact(datum[:method], url, datum[:status] || result.status, bm) HttpLog.log_benchmark(bm) end result end alias_method :orig_request_call, :request_call def request_call(datum) url = _httplog_url(datum) if HttpLog.url_approved?(url) HttpLog.log_request(datum[:method], _httplog_url(datum)) HttpLog.log_headers(datum[:headers]) HttpLog.log_data(datum[:body]) if datum[:method] == :post end orig_request_call(datum) end alias_method :orig_response, :response def response(datum={}) return orig_response(datum) unless HttpLog.url_approved?(_httplog_url(datum)) bm = Benchmark.realtime do datum = orig_response(datum) end response = datum[:response] HttpLog.log_status(response[:status]) HttpLog.log_body(response[:body]) datum end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
httplog-0.2.8 | lib/httplog/adapters/excon.rb |
httplog-0.2.7 | lib/httplog/adapters/excon.rb |
httplog-0.2.6 | lib/httplog/adapters/excon.rb |
httplog-0.2.5 | lib/httplog/adapters/excon.rb |