Module: Console::Adapter::Rails

Defined in:
lib/console/adapter/rails.rb,
lib/console/adapter/rails/version.rb,
lib/console/adapter/rails/active_record.rb,
lib/console/adapter/rails/action_controller.rb,
lib/console/adapter/rails/logger.rb

Overview

A Rails adapter for the console logger.

Defined Under Namespace

Modules: ActionController, ActiveRecord Classes: Logger

Constant Summary collapse

VERSION =
"0.3.1"

Class Method Summary collapse

Class Method Details

.apply!(notifications: ActiveSupport::Notifications, configuration: ::Rails.configuration) ⇒ Object

Apply the Rails adapter to the current process and Rails application.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/console/adapter/rails.rb', line 17

def self.apply!(notifications: ActiveSupport::Notifications, configuration: ::Rails.configuration)
  if configuration
    Logger.apply!(configuration: configuration)
  end
  
  if notifications
    # Clear out all the existing subscribers otherwise you'll get double the logs:
    notifications.notifier = ActiveSupport::Notifications::Fanout.new
    
    # Add our own subscribers:
    Rails::ActionController.apply!(notifications: notifications)
    Rails::ActiveRecord.apply!(notifications: notifications)
  end
end