Sha256: a5563831c56b743c76dd404b3f47c254945ef18a7931712a85472fe1f5832f4b

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 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
        ::Rails.configuration.middleware
          .insert_before 'Rack::Runtime', Airbrake::UserInformer
      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

1 entries across 1 versions & 1 rubygems

Version Path
airbrake-4.2.1 lib/airbrake/rails.rb