Class: Ey::Core::Logger

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

Instance Method Summary collapse

Constructor Details

#initialize(app, logger = nil) ⇒ Logger

Returns a new instance of Logger.



4
5
6
7
# File 'lib/ey-core/logger.rb', line 4

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

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/ey-core/logger.rb', line 11

def call(env)
  debug "REQUEST: #{env[:method].upcase} #{env[:url].to_s}"
  debug('request') { dump_headers env[:request_headers] }
  debug('request.body') { env[:body] }
  debug('')
  super
end

#on_complete(env) ⇒ Object



19
20
21
22
23
24
# File 'lib/ey-core/logger.rb', line 19

def on_complete(env)
  debug "RESPONSE: #{env[:status]}"
  debug('response') { dump_headers env[:response_headers] }
  debug('response.body') { env[:body] }
  debug('')
end