Class: JustGiving::Logger

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/justgiving/logger.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/justgiving/logger.rb', line 6

def call(env)
  puts "Request: #{env[:method].to_s.upcase} #{env[:url]}"
  puts "Request body: #{env[:body]}" unless env[:body].nil?

  @app.call(env).on_complete do
    puts "Response: #{env[:status]} #{env[:body]}" unless env[:status] == 200
  end
end