Class: Logged::LogSubscriber::ActionController

Inherits:
Base
  • Object
show all
Defined in:
lib/logged/log_subscriber/action_controller.rb

Overview

Log subscriber for ActionController events

Instance Method Summary collapse

Methods inherited from Base

component, #logger

Instance Method Details

#halted_callback(event) ⇒ Object



34
35
36
# File 'lib/logged/log_subscriber/action_controller.rb', line 34

def halted_callback(event)
  Thread.current[:logged_action_controller_filter] = event.payload[:filter]
end

#process_action(event) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/logged/log_subscriber/action_controller.rb', line 10

def process_action(event)
  return if ignore?(event, :info)

  payload = event.payload

  data = {
    event: event.name
  }

  data.merge!(extract_request(payload))
  data.merge!(cached_event_data)
  data.merge!(extract_path(payload))
  data.merge!(extract_status(payload))
  data.merge!(extract_runtimes(payload))

  data[:duration] = event.duration.to_f.round(2)

  info(event, data)
end

#redirect_to(event) ⇒ Object



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

def redirect_to(event)
  Thread.current[:logged_action_controller_location] = event.payload[:location]
end