Class: Deimos::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/deimos/logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, logger = Deimos.logger) ⇒ Logger

Returns a new instance of Logger.



8
9
10
11
# File 'lib/deimos/logger.rb', line 8

def initialize(app, logger = Deimos.logger)
  @app = app
  @logger = logger
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/deimos/logger.rb', line 13

def call(env)
  began_at = Rack::Utils.clock_time
  status, header, body = @app.call(env)
  header = Rack::Utils::HeaderHash.new(header)
  body = Rack::BodyProxy.new(body) { log(env, status, header, began_at) }
  [status, header, body]
end