Class: Superlogger::ActionControllerLogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- Superlogger::ActionControllerLogSubscriber
- Defined in:
- lib/superlogger/action_controller_log_subscriber.rb
Constant Summary collapse
- INTERNAL_PARAMS =
%w(controller action format _method only_path)
Instance Method Summary collapse
-
#process_action(event) ⇒ Object
end of controller action.
-
#start_processing(event) ⇒ Object
start of controller action.
Instance Method Details
#process_action(event) ⇒ Object
end of controller action
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/superlogger/action_controller_log_subscriber.rb', line 13 def process_action(event) payload = event.payload total_duration = event.duration.to_f.round(2) view_duration = payload[:view_runtime].to_f.round(2) if payload.key?(:view_runtime) db_duration = payload[:db_runtime].to_f.round(2) if payload.key?(:db_runtime) if payload[:exception] status = ActionDispatch::ExceptionWrapper.status_code_for_exception(payload[:exception][0]) logger.fatal status: status, total_duration: total_duration, view_duration: view_duration, db_duration: db_duration, exception: payload[:exception] else # Assume status 401 if action finishes without status code and no exception # https://github.com/pcg79/devise/commit/1e2dab3c0ce49efe2b5940c15f47388c69d6731b payload[:status] ||= 401 logger.info status: payload[:status], total_duration: total_duration, view_duration: view_duration, db_duration: db_duration end end |
#start_processing(event) ⇒ Object
start of controller action
6 7 8 9 10 |
# File 'lib/superlogger/action_controller_log_subscriber.rb', line 6 def start_processing(event) payload = event.payload logger.debug controller: payload[:controller], action: payload[:action], params: payload[:params].except(*INTERNAL_PARAMS) end |