Sha256: 7516ea36a3358fe485daf1a9b6813f281a3499ff356ae65ecb772599a59aac9b
Contents?: true
Size: 780 Bytes
Versions: 1
Compression:
Stored size: 780 Bytes
Contents
class Assemble::Logger < Faraday::Response::Middleware extend Forwardable def initialize(app, logger = nil) super(app) @logger = logger || ::Logger.new(nil) end def_delegators :@logger, :debug, :info, :warn, :error, :fatal def call(env) debug "REQUEST: #{env[:method].upcase} #{env[:url].to_s}" debug('request') { dump_headers env[:request_headers] } debug('request.body') { env[:body] } super end def on_complete(env) debug "RESPONSE: #{env[:status]} #{env[:method].upcase} #{env[:url].to_s}" debug('response') { dump_headers env[:response_headers] } debug('response.body') { env[:body] } debug('') end private def dump_headers(headers) (headers || {}).map { |k,v| "#{k}: #{v.inspect}" }.join("\n") end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
assemble-0.0.1 | lib/assemble/logger.rb |