Class: Stackify::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/stackify/engine.rb

Instance Method Summary collapse

Instance Method Details

#set_console_logs(new_logger) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/stackify/engine.rb', line 42

def set_console_logs new_logger
  if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new('6.0')
    ActiveSupport.on_load(:action_controller_base) do
      logger = new_logger
    end
    ActiveSupport.on_load(:action_view) do
      logger = new_logger
    end
    ActiveSupport.on_load(:active_record) do
      logger = new_logger
    end
  else
    # Handle the stdout logs from Action Controller
    ActionController::Base.logger = new_logger

    # Handle the stdout logs from Action View
    ActionView::Base.logger = new_logger

    # Handle the stdout logs from Active Record
    ActiveRecord::Base.logger = new_logger
  end
end