class Deas::SummaryLogging

Public Instance Methods

call!(env) click to toggle source

This the real Rack call interface. It adds logging after super-ing to the common logging behavior.

Calls superclass method Deas::BaseLogging#call!
# File lib/deas/logging.rb, line 97
def call!(env)
  env['deas.logging'] = Proc.new{ |msg| } # no-op
  status, headers, body = super(env)
  request = Rack::Request.new(env)
  line_attrs = {
    'method'  => request.request_method,
    'path'    => request.path,
    'params'  => env['deas.params'],
    'splat'   => env['deas.splat'],
    'time'    => env['deas.time_taken'],
    'status'  => status
  }
  if env['deas.handler_class']
    line_attrs['handler'] = env['deas.handler_class'].name
  end
  if headers.key?('Location')
    line_attrs['redir'] = headers['Location']
  end
  log SummaryLine.new(line_attrs)
  [status, headers, body]
end