Class: Rack::CommonLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/puma/rack_patch.rb

Overview

Patch CommonLogger to use after_reply.

Simply request this file and CommonLogger will be a bit more efficient.

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/puma/rack_patch.rb', line 11

def call(env)
  began_at = Time.now
  status, header, body = @app.call(env)
  header = Utils::HeaderHash.new(header)

  if ary = env['rack.after_reply']
    ary << lambda { log(env, status, header, began_at) }
  else
    body = BodyProxy.new(body) { log(env, status, header, began_at) }
  end

  [status, header, body]
end