Sha256: 1dce33451a4cd682d05e5ebcfc5c1acf182adc241f8627236bf0be3dde2ce3ec
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
require 'logger' module Excon class LoggingInstrumentor def self.instrument(name, params = {}) params = params.dup logger = params[:logger] || Logger.new($stderr) # reduce duplication/noise of output params.delete(:connection) params.delete(:stack) if params.has_key?(:headers) && params[:headers].has_key?('Authorization') params[:headers] = params[:headers].dup params[:headers]['Authorization'] = "REDACTED" end if params.has_key?(:password) params[:password] = "REDACTED" end if name.include?('request') info = "request: " + params[:scheme] + "://" + File.join(params[:host], params[:path]) if params[:query] info << "?" if params[:query].is_a?(Hash) info << params.to_a.map{ |key,value| "#{key}=#{value}" }.join('&') else info << params[:query] end end else response_type = name.split('.').last if params[:body] info = "#{response_type}: " + params[:body] end end logger.log(Logger::INFO, info) if info yield if block_given? end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
excon-0.80.1 | lib/excon/instrumentors/logging_instrumentor.rb |
excon-0.80.0 | lib/excon/instrumentors/logging_instrumentor.rb |
excon-0.79.0 | lib/excon/instrumentors/logging_instrumentor.rb |