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



26
27
28
# File 'lib/yarder/action_controller/log_subscriber.rb', line 26

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

#process_action(event) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/yarder/action_controller/log_subscriber.rb', line 17

def process_action(event)
  payload   = event.payload

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

  root['duration']['controller'] = event.duration
end

#redirect_to(event) ⇒ Object



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

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

#send_data(event) ⇒ Object



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

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

#send_file(event) ⇒ Object



30
31
32
33
# File 'lib/yarder/action_controller/log_subscriber.rb', line 30

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

#start_processing(event) ⇒ Object



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

def start_processing(event)
  payload = event.payload

  entry['name'] = payload[:controller]
  entry['action'] = payload[:action]
  entry['path'] = payload[:path]
  entry['format']  = payload[:format].to_s.downcase
end