Sha256: af719886b552b5344f2ddaaac0d2e3fc234121041daa94b6e7199fb39e185ac9

Contents?: true

Size: 1.91 KB

Versions: 10

Compression:

Stored size: 1.91 KB

Contents

require 'honeybadger'
require 'honeybadger/rails/controller_methods'
require 'honeybadger/rails/action_controller_catcher'

module Honeybadger
  module Rails
    def self.initialize
      if defined?(ActionController::Base)
        ActionController::Base.send(:include, Honeybadger::Rails::ActionControllerCatcher)
        ActionController::Base.send(:include, Honeybadger::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)
        ::Rails.configuration.middleware.insert_after 'ActionController::Failsafe',
                                                      Honeybadger::Rack
        ::Rails.configuration.middleware.insert_after 'Rack::Lock',
                                                      Honeybadger::UserInformer
        ::Rails.configuration.middleware.insert_after Honeybadger::UserInformer,
                                                      Honeybadger::UserFeedback
      end

      Honeybadger.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

      if defined?(::Rails.configuration) && ::Rails.configuration.respond_to?(:after_initialize)
        ::Rails.configuration.after_initialize do
          Honeybadger.ping(Honeybadger.configuration)
        end
      end
    end
  end
end

Honeybadger::Rails.initialize

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
honeybadger-1.13.2 lib/honeybadger/rails.rb
honeybadger-1.13.1 lib/honeybadger/rails.rb
honeybadger-1.13.0 lib/honeybadger/rails.rb
honeybadger-1.11.2 lib/honeybadger/rails.rb
honeybadger-1.11.1 lib/honeybadger/rails.rb
honeybadger-1.11.0 lib/honeybadger/rails.rb
honeybadger-1.11.0.beta4 lib/honeybadger/rails.rb
honeybadger-1.11.0.beta3 lib/honeybadger/rails.rb
honeybadger-1.11.0.beta2 lib/honeybadger/rails.rb
honeybadger-1.11.0.beta1 lib/honeybadger/rails.rb