Sha256: 28eb8889172f62721ed1eeff67dacf0075d64171997c8efd15aadda1182ef950
Contents?: true
Size: 1.02 KB
Versions: 12
Compression:
Stored size: 1.02 KB
Contents
require 'faraday_middleware/response_middleware' module ZendeskAPI module Middleware module Response # Faraday middleware to handle logging # @private class Logger < Faraday::Response::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) super end def on_complete(env) @logger.info("Status #{env[:status].to_s}") @logger.debug dump_debug(env, :response_headers) 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
12 entries across 12 versions & 1 rubygems