lib/ezlog/railtie.rb in ezlog-0.8.0 vs lib/ezlog/railtie.rb in ezlog-0.9.0

- old
+ new

@@ -2,10 +2,11 @@ class Railtie < Rails::Railtie config.ezlog = ActiveSupport::OrderedOptions.new config.ezlog.enable_sequel_logging = false config.ezlog.log_only_whitelisted_params = false config.ezlog.whitelisted_params = [:controller, :action] + config.ezlog.exclude_paths = [] initializer "ezlog.initialize" do require "ezlog/rails/extensions" end @@ -27,20 +28,30 @@ end initializer 'ezlog.configure_rails_middlewares' do |app| app.config.middleware.insert_after ::ActionDispatch::RequestId, Ezlog::Rails::RequestLogContext app.config.middleware.delete ::Rails::Rack::Logger - app.config.middleware.insert_before ::ActionDispatch::DebugExceptions, Ezlog::Rails::AccessLog, Ezlog.logger('AccessLog'), whitelisted_params(app) + app.config.middleware.insert_before ::ActionDispatch::DebugExceptions, Ezlog::Rails::AccessLog, Ezlog.logger('AccessLog'), config.ezlog app.config.middleware.insert_after ::ActionDispatch::DebugExceptions, Ezlog::Rails::LogExceptions, Ezlog.logger('Application') end config.after_initialize do - Ezlog::Rails::LogSubscriber.detach ::ActionController::LogSubscriber - Ezlog::Rails::LogSubscriber.detach ::ActionView::LogSubscriber - if defined? ::ActiveRecord - Ezlog::Rails::LogSubscriber.detach ::ActiveRecord::LogSubscriber - Ezlog::Rails::LogSubscriber.attach Ezlog::Rails::ActiveRecord::LogSubscriber, :active_record + case ::Rails::VERSION::MAJOR + when 6 + ::ActionController::LogSubscriber.detach_from :action_controller + ::ActionView::LogSubscriber.detach_from :action_view + if defined? ::ActiveRecord + ::ActiveRecord::LogSubscriber.detach_from :active_record + Ezlog::Rails::LogSubscriber.attach Ezlog::Rails::ActiveRecord::LogSubscriber, :active_record + end + else + Ezlog::Rails::LogSubscriber.detach ::ActionController::LogSubscriber + Ezlog::Rails::LogSubscriber.detach ::ActionView::LogSubscriber + if defined? ::ActiveRecord + Ezlog::Rails::LogSubscriber.detach ::ActiveRecord::LogSubscriber + Ezlog::Rails::LogSubscriber.attach Ezlog::Rails::ActiveRecord::LogSubscriber, :active_record + end end end config.before_configuration do |app| app.config.logger = Ezlog.logger('Application') @@ -59,12 +70,8 @@ end end def disable_rack_timeout_logging ::Rack::Timeout::Logger.logger = ::Logger.new(nil) - end - - def whitelisted_params(app) - app.config.ezlog.log_only_whitelisted_params ? app.config.ezlog.whitelisted_params : nil end end end