Class: Yarder::ActionController::LogSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/yarder/action_controller/log_subscriber.rb

Constant Summary collapse

INTERNAL_PARAMS =
%w(controller action format _method only_path)

Instance Method Summary collapse

Instance Method Details

#halted_callback(event) ⇒ Object



35
36
37
# File 'lib/yarder/action_controller/log_subscriber.rb', line 35

def halted_callback(event)
  entry.fields['halted_callback'] = event.payload[:filter]
end

#process_action(event) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/yarder/action_controller/log_subscriber.rb', line 19

def process_action(event)

  payload   = event.payload
  #TODO Think about additions. Comment out for the moment to shut up warnings
  #additions = ::ActionController::Base.log_process_action(payload)

  params = payload[:params].except(*INTERNAL_PARAMS)
  entry.fields['parameters'] = params unless params.empty?

  entry.fields['controller_duration'] = event.duration

  #TODO  What on earth are additions and how should we handle them?
  # message << " (#{additions.join(" | ")})" unless additions.blank?

end

#redirect_to(event) ⇒ Object



44
45
46
# File 'lib/yarder/action_controller/log_subscriber.rb', line 44

def redirect_to(event)
  entry.fields['redirect_to'] = event.payload[:location]
end

#send_data(event) ⇒ Object



48
49
50
51
# File 'lib/yarder/action_controller/log_subscriber.rb', line 48

def send_data(event)
  entry.fields['send_data'] = event.payload[:filename]
  entry.fields['send_data_duration'] = event.duration
end

#send_file(event) ⇒ Object



39
40
41
42
# File 'lib/yarder/action_controller/log_subscriber.rb', line 39

def send_file(event)
  entry.fields['send_file'] = event.payload[:path]
  entry.fields['send_file_duration'] = event.duration
end

#start_processing(event) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/yarder/action_controller/log_subscriber.rb', line 8

def start_processing(event)
  payload = event.payload

  entry.fields['controller'] = payload[:controller]
  entry.fields['action'] = payload[:action]

  format  = payload[:format]
  entry.fields['format']  = format.to_s.downcase if format.is_a?(Symbol)

end