Sha256: fc052fe8cdb9ca30a314d79bd664b0933a37aaa28bc3ea14748ad2912938b910

Contents?: true

Size: 1.89 KB

Versions: 10

Compression:

Stored size: 1.89 KB

Contents

require 'airbrake'
require 'airbrake/rails/controller_methods'
require 'airbrake/rails/action_controller_catcher'
require 'airbrake/rails/error_lookup'

module Airbrake
  module Rails
    def self.initialize
      if defined?(ActionController::Base)
        ActionController::Base.send(:include, Airbrake::Rails::ActionControllerCatcher)
        ActionController::Base.send(:include, Airbrake::Rails::ErrorLookup)
        ActionController::Base.send(:include, Airbrake::Rails::ControllerMethods)
      end

      rails_logger = if defined?(::Rails.logger)
                       ::Rails.logger
                     elsif defined?(RAILS_DEFAULT_LOGGER)
                       RAILS_DEFAULT_LOGGER
                     end

      if defined?(::Rails.configuration) && ::Rails.configuration.respond_to?(:middleware)
        if defined?(::ActionController::Failsafe)
          ::Rails.configuration.middleware.insert_after 'ActionController::Failsafe',
                                                        Airbrake::Rack
        end
        if defined?(::Rack::Lock)
          ::Rails.configuration.middleware.insert_after 'Rack::Lock',
                                                        Airbrake::UserInformer
        else
          ::Rails.configuration.middleware.insert_before 'Rack::Runtime',
                                                         Airbrake::UserInformer
        end
      end

      Airbrake.configure(true) do |config|
        config.logger           = rails_logger
        config.environment_name = defined?(::Rails.env) && ::Rails.env || defined?(RAILS_ENV) && RAILS_ENV
        config.project_root     = defined?(::Rails.root) && ::Rails.root || defined?(RAILS_ROOT) && RAILS_ROOT
        config.framework        = defined?(::Rails.version) && "Rails: #{::Rails.version}" || defined?(::Rails::VERSION::STRING) && "Rails: #{::Rails::VERSION::STRING}"
      end
    end
  end
end

Airbrake::Rails.initialize

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
airbrakeV4rails5-4.3.8 lib/airbrake/rails.rb
airbrake-4.3.8 lib/airbrake/rails.rb
airbrake-4.3.7 lib/airbrake/rails.rb
airbrake-4.3.6 lib/airbrake/rails.rb
airbrake-4.3.5 lib/airbrake/rails.rb
airbrake-4.3.4 lib/airbrake/rails.rb
airbrake-4.3.3 lib/airbrake/rails.rb
airbrake-4.3.2 lib/airbrake/rails.rb
airbrake-4.3.1 lib/airbrake/rails.rb
airbrake-4.3.0 lib/airbrake/rails.rb