Module: Lumberjack::Rails::ActionControllerLogSubscriberExtension

Extended by:
ActiveSupport::Concern
Defined in:
lib/lumberjack/rails/action_controller_log_subscriber_extension.rb

Overview

This extension to the ActionController::LogSubscriber class allows specifying log attributes that will only be applied on the process_action event. This log entry already serves as the canonical log entry for requests and includes metadata such as duration, allocations, etc. With this extension you can add whatever additonal attributes you want to summarize what happened during the request as log attributes. This gives you more flexibility to add context to your request logs.

You can add dynamically evaluated attributes by providing a block that takes the event as an argument.

Examples:

ActionController::LogSubscriber.add_process_log_attribute(:ip_address) do |event|
  event.payload.request.remote_ip
end

ActionController::LogSubscriber.add_process_log_attribute(:duration) do |event|
  event.duration
end

Instance Method Summary collapse

Instance Method Details

#process_action(event) ⇒ Object

:nodoc:



86
87
88
89
90
# File 'lib/lumberjack/rails/action_controller_log_subscriber_extension.rb', line 86

def process_action(event) # :nodoc:
  with_process_logger_attributes(event) do
    super
  end
end