Class: Deas::SummaryLogging

Inherits:
BaseLogging show all
Defined in:
lib/deas/logging.rb

Instance Method Summary collapse

Methods inherited from BaseLogging

#call, #initialize, #log, #log_error

Constructor Details

This class inherits a constructor from Deas::BaseLogging

Instance Method Details

#call!(env) ⇒ Object

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



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# 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,
    'handler' => env['deas.handler_class_name'],
    'params'  => env['deas.params'],
    'time'    => env['deas.time_taken'],
    'status'  => status
  }
  if headers.key?('Location')
    line_attrs['redir'] = headers['Location']
  end
  log SummaryLine.new(line_attrs)
  [ status, headers, body ]
end