Sha256: 410288ece09210d72203ca5826358bdea48cb5aaeaf6e5bebc33e9afc7aad137

Contents?: true

Size: 1.35 KB

Versions: 5

Compression:

Stored size: 1.35 KB

Contents

# Rails 2.x hooks
# For Rails 3+ hooks, see railtie.rb

require "bugsnag"
require "bugsnag/rails/controller_methods"
require "bugsnag/rails/action_controller_rescue"
require "bugsnag/middleware/rails2_request"
require "bugsnag/middleware/callbacks"

module Bugsnag
  module Rails
    def self.initialize
      if defined?(ActionController::Base)
        ActionController::Base.send(:include, Bugsnag::Rails::ActionControllerRescue)
        ActionController::Base.send(:include, Bugsnag::Rails::ControllerMethods)
      end

      # Try to find where to log to
      rails_logger = nil
      if defined?(::Rails.logger)
        rails_logger = ::Rails.logger
      elsif defined?(RAILS_DEFAULT_LOGGER)
        rails_logger = RAILS_DEFAULT_LOGGER
      end

      Bugsnag.configure do |config|
        config.logger ||= rails_logger
        config.release_stage = RAILS_ENV  if defined?(RAILS_ENV)
        config.project_root = RAILS_ROOT if defined?(RAILS_ROOT)

        config.middleware.use Bugsnag::Middleware::Rails2Request
      end

      # Auto-load configuration settings from config/bugsnag.yml if it exists
      config_file = File.join(RAILS_ROOT, "config", "bugsnag.yml")
      config = YAML.load_file(config_file) if File.exists?(config_file)
      Bugsnag.configure(config[RAILS_ENV] ? config[RAILS_ENV] : config) if config
    end
  end
end

Bugsnag::Rails.initialize

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bugsnag-1.2.3 lib/bugsnag/rails.rb
bugsnag-1.2.2 lib/bugsnag/rails.rb
bugsnag-1.2.1 lib/bugsnag/rails.rb
bugsnag-1.2.0 lib/bugsnag/rails.rb
bugsnag-1.2.0.beta lib/bugsnag/rails.rb