Sha256: 65ef942b6cb221098cc9c97bdfeeda55324ac5fd95c9d7021133f30bdb582bd7
Contents?: true
Size: 997 Bytes
Versions: 55
Compression:
Stored size: 997 Bytes
Contents
module ZendeskAPI module Middleware module Response # Faraday middleware to handle logging # @private class Logger < Faraday::Middleware def initialize(app, logger = nil) super(app) @logger = logger || begin require 'logger' ::Logger.new(STDOUT) end end def call(env) @logger.info "#{env[:method]} #{env[:url].to_s}" @logger.debug dump_debug(env, :request_headers) @app.call(env).on_complete do |env| @logger.info("Status #{env[:status].to_s}") @logger.debug dump_debug(env, :response_headers) end end private def dump_debug(env, headers_key) info = env[headers_key].map { |k, v| " #{k}: #{v.inspect}" }.join("\n") unless env[:body].nil? info.concat("\n") info.concat(env[:body].inspect) end info end end end end end
Version data entries
55 entries across 55 versions & 1 rubygems