module FailbotRails

Constants

VERSION

Attributes

_setup[R]

Public Class Methods

_failbot_safe_context(context) click to toggle source
# File lib/failbot_rails.rb, line 74
def self._failbot_safe_context(context)
  new_context = {}.merge(context)
  filters = Rails.application.config.filter_parameters
  filter = ActiveSupport::ParameterFilter.new(filters)

  if new_context.key?(:params)
    new_context[:params] = filter.filter(new_context[:params])
  end

  new_context
end
setup(app_name, default_context={}) click to toggle source
# File lib/failbot_rails.rb, line 9
def self.setup(app_name, default_context={})
  if _setup
    fail "FailbotRails already setup"
  end

  if !app_name.respond_to?(:to_str) || app_name.to_str.empty?
    raise ArgumentError, "app_name argument is required"
  end

  settings = ENV.to_hash

  # sensible defaults
  if Rails.env.development? || Rails.env.test?
    settings["FAILBOT_BACKEND"] ||= "memory"

    if !settings.key?("FAILBOT_RAISE")
      settings["FAILBOT_RAISE"] = "1"
    end
  end

  Failbot.setup(settings, default_context.merge({:app => app_name.to_str}))
  Failbot.install_unhandled_exception_hook!

  @_setup = true
end