Module: Logsy::ControllerHooks

Extended by:
ActiveSupport::Concern
Defined in:
lib/logsy/controller_hooks.rb

Overview

Mix into your ApplicationController (or specific controllers) to:

1. Capture the request's UUID into Logsy.context.request_id, so every
   log line emitted during the request carries it.
2. Emit a single "wide event" log line at end of request with the
   method, path, status, duration_ms, controller, action, error, and
   every Current.* attribute that was set during the request.

Usage:

class ApplicationController < ActionController::API
  include Logsy::ControllerHooks
end

Override ‘logsy_request_summary_extras` in your controller to add custom fields to the wide event:

def logsy_request_summary_extras
  { ip: request.remote_ip, user_agent: request.user_agent }
end