Class: Epilog::Rails::ActionControllerSubscriber

Inherits:
LogSubscriber
  • Object
show all
Defined in:
lib/epilog/rails/action_controller_subscriber.rb

Constant Summary collapse

RAILS_PARAMS =
%i[controller action format _method only_path].freeze

Instance Attribute Summary

Attributes inherited from LogSubscriber

#logger

Instance Method Summary collapse

Methods inherited from LogSubscriber

#initialize

Constructor Details

This class inherits a constructor from Epilog::Rails::LogSubscriber

Instance Method Details

#halted_callback(event) ⇒ Object



48
49
50
51
52
53
# File 'lib/epilog/rails/action_controller_subscriber.rb', line 48

def halted_callback(event)
  info do
    basic_message(event, 'Filter chain halted as ' \
      "#{event.payload[:filter].inspect} rendered or redirected")
  end
end

#process_actionObject



33
34
# File 'lib/epilog/rails/action_controller_subscriber.rb', line 33

def process_action(*)
end

#process_request(event) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/epilog/rails/action_controller_subscriber.rb', line 18

def process_request(event)
  info do
    event.payload[:context].merge(
      message: response_string(event),
      request: short_request_hash(event),
      response: response_hash(event),
      metrics: process_metrics(event.payload[:metrics]
        .merge(request_runtime: event.duration.round(2)))
    )
  end
end

#redirect_to(event) ⇒ Object



44
45
46
# File 'lib/epilog/rails/action_controller_subscriber.rb', line 44

def redirect_to(event)
  info { basic_message(event, "Redirect > #{event.payload[:location]}") }
end

#request_received(event) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/epilog/rails/action_controller_subscriber.rb', line 9

def request_received(event)
  info do
    {
      message: "#{request_string(event)} started",
      request: request_hash(event)
    }
  end
end

#send_data(event) ⇒ Object



36
37
38
# File 'lib/epilog/rails/action_controller_subscriber.rb', line 36

def send_data(event)
  info { basic_message(event, "Sent data #{event.payload[:filename]}") }
end

#send_file(event) ⇒ Object



40
41
42
# File 'lib/epilog/rails/action_controller_subscriber.rb', line 40

def send_file(event)
  info { basic_message(event, "Sent file #{event.payload[:path]}") }
end

#start_processingObject



30
31
# File 'lib/epilog/rails/action_controller_subscriber.rb', line 30

def start_processing(*)
end

#unpermitted_parameters(event) ⇒ Object



55
56
57
58
59
60
# File 'lib/epilog/rails/action_controller_subscriber.rb', line 55

def unpermitted_parameters(event)
  debug do
    basic_message(event, 'Unpermitted parameters: ' \
      "#{event.payload[:keys].join(', ')}")
  end
end