Class: LogSanity::LogSubscriber::ActionController
- Inherits:
-
Base
- Object
- ActiveSupport::LogSubscriber
- Base
- LogSanity::LogSubscriber::ActionController
- Defined in:
- lib/log_sanity/log_subscribers/action_controller.rb
Constant Summary collapse
- INTERNAL_PARAMS =
%w(controller action format _method only_path)
Instance Method Summary collapse
- #halted_callback(event) ⇒ Object
- #process_action(event) ⇒ Object
- #redirect_to(event) ⇒ Object
- #send_data(event) ⇒ Object
- #send_file(event) ⇒ Object
Instance Method Details
#halted_callback(event) ⇒ Object
38 39 40 |
# File 'lib/log_sanity/log_subscribers/action_controller.rb', line 38 def halted_callback(event) log 'filter_chain_halt', event.payload[:filter].inspect end |
#process_action(event) ⇒ Object
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_controller.rb', line 6 def process_action(event) payload = event.payload params = payload[:params].except(*INTERNAL_PARAMS) format = payload[:format] # log 'method', payload[:method] # log 'path', payload[:path] # log 'controller', payload[:controller] # log 'action', payload[:action] log 'route', "#{payload[:controller]}##{payload[:action]}" log 'format', format log 'params', params if params.present? status = payload[:status] if status.nil? && payload[:exception].present? exception_class_name = payload[:exception].first status = ::ActionDispatch::ExceptionWrapper.status_code_for_exception(exception_class_name) end durations = {'total' => event.duration.round} additions = ::ActionController::Base.log_process_action(payload) additions.each do |add| if add =~ /^([^:]+):?\s*([0-9.]+)(ms)?/ ms = $2.to_f.round durations[$1.downcase] = ms if ms > 0 end end log 'duration', durations log 'status', status end |
#redirect_to(event) ⇒ Object
46 47 48 |
# File 'lib/log_sanity/log_subscribers/action_controller.rb', line 46 def redirect_to(event) log 'redirect', event.payload[:location] end |
#send_data(event) ⇒ Object
50 51 52 |
# File 'lib/log_sanity/log_subscribers/action_controller.rb', line 50 def send_data(event) log 'send_data', event.payload[:filename] || 'binary' end |
#send_file(event) ⇒ Object
42 43 44 |
# File 'lib/log_sanity/log_subscribers/action_controller.rb', line 42 def send_file(event) log 'send_file', event.payload[:path] end |