Class: LogSanity::LogSubscriber::ActionDispatch

Inherits:
Base
  • Object
show all
Defined in:
lib/log_sanity/log_subscribers/action_dispatch.rb

Instance Method Summary collapse

Instance Method Details

#redirect(event) ⇒ Object



38
39
40
# File 'lib/log_sanity/log_subscribers/action_dispatch.rb', line 38

def redirect(event)
  log 'redirect', event.payload[:location]
end

#request(event) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/log_sanity/log_subscribers/action_dispatch.rb', line 5

def request(event)
  payload = event.payload
  return if payload[:silence]

  info do
    request = payload[:request]
    response = payload[:response]
    method = payload[:method] || (request.request_method rescue nil) || 'UNKNOWN'
    f2 = {
      'at' => event_start(event),
      'event' => "#{request.scheme}_#{method.downcase}",
      'ip' => request.remote_ip,
      'rq' => request.uuid,
      # 'params' => request.filtered_params,
      # 'path' => request.filtered_path,
    }

    # unless fields['route']
    #   # most errors repopulate path, so look for the original one first.
    #   # original_path is, however, unfiltered.
    #   fields['path'] = payload[:env]['action_dispatch.original_path']
    #   fields['path'] ||= request.filtered_path
    # end

    fields['duration'] ||= {}
    fields['duration']['total'] = event.duration.round
      # rewrites 'total', which includes more of time spent in middleware
    fields['status'] ||= response[0].to_i if response
    compute_tags(request)
    f2.merge fields
  end
end