Class: Crowd::Client::Logger

Inherits:
Faraday::Response::Middleware
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/crowd-client/logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, logger = nil) ⇒ Logger

Returns a new instance of Logger.



5
6
7
8
9
10
11
# File 'lib/crowd-client/logger.rb', line 5

def initialize(app, logger = nil)
  super(app)
  @logger = logger || begin
    require 'logger'
    ::Logger.new(STDOUT)
  end
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
# File 'lib/crowd-client/logger.rb', line 15

def call(env)
  info "#{env[:method]} #{env[:url].to_s}"
  debug "------ Request ------\n#{dump_headers env[:request_headers]}\nBody: #{env[:body]}"
  super
end

#on_complete(env) ⇒ Object



21
22
23
24
# File 'lib/crowd-client/logger.rb', line 21

def on_complete(env)
  info "Status: #{env[:status].to_s}"
  debug "------ Response ------\n#{dump_headers env[:response_headers]}\nBody: #{env[:response].body}"
end