Module: Bugsnag::Rails

Defined in:
lib/bugsnag/rails/action_controller_rescue.rb,
lib/bugsnag/rails.rb,
lib/bugsnag/rails/controller_methods.rb,
lib/bugsnag/rails/active_record_rescue.rb

Overview

Rails 2.x only

Defined Under Namespace

Modules: ActionControllerRescue, ActiveRecordRescue, ControllerMethods

Class Method Summary collapse

Class Method Details

.initializeObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bugsnag/rails.rb', line 13

def self.initialize
  if defined?(ActionController::Base)
    ActionController::Base.send(:include, Bugsnag::Rails::ActionControllerRescue)
    ActionController::Base.send(:include, Bugsnag::Rails::ControllerMethods)
  end
  if defined?(ActiveRecord::Base) && Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("4.3")
    unless ActiveRecord::Base.respond_to?(:raise_in_transactional_callbacks) && ActiveRecord::Base.raise_in_transactional_callbacks
      ActiveRecord::Base.send(:include, Bugsnag::Rails::ActiveRecordRescue)
    end
  end

  Bugsnag.configure do |config|
    config.logger ||= rails_logger
    config.release_stage = rails_env if rails_env
    config.project_root = rails_root if rails_root

    config.middleware.insert_before(Bugsnag::Middleware::Callbacks,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

  Bugsnag.configuration.app_type = "rails"
end

.rails_envObject



48
49
50
51
52
53
54
# File 'lib/bugsnag/rails.rb', line 48

def self.rails_env
  if defined?(::Rails.env)
    ::Rails.env
  elsif defined?(RAILS_ENV)
    RAILS_ENV
  end
end

.rails_loggerObject



40
41
42
43
44
45
46
# File 'lib/bugsnag/rails.rb', line 40

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

.rails_rootObject



56
57
58
59
60
61
62
# File 'lib/bugsnag/rails.rb', line 56

def self.rails_root
  if defined?(::Rails.root)
    ::Rails.root
  elsif defined?(RAILS_ROOT)
    RAILS_ROOT
  end
end