Module: Failbot::Compat

Included in:
Failbot
Defined in:
lib/failbot/compat.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#backendObject

Load and initialize the exception reporting backend as specified by the ‘backend’ configuration option.

Raises ArgumentError for invalid backends.



98
99
100
# File 'lib/failbot/compat.rb', line 98

def backend
  @backend ||= backend!
end

Instance Method Details

#backend!Object



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/failbot/compat.rb', line 103

def backend!
  warn "#{caller[0]} Failbot.backend! is deprecated and will be " \
    "removed in subsequent releases."
  case backend_name
  when 'memory'
    Failbot::MemoryBackend.new
  when 'file'
    Failbot::FileBackend.new(config['file_path'])
  when 'heroku', 'http'
    if backend_name == "heroku"
      warn "The Failbot \"heroku\" backend is deprecated. Use \"http\" " \
        "instead. #{caller[1]}"
    end
    Failbot::HerokuBackend.new(config['haystack'])
  else
    raise ArgumentError, "Unknown backend: #{backend_name.inspect}"
  end
end

#backend_nameObject

The name of the backend that should be used to post exceptions to the exceptions-collection service. The fellowing backends are available:

memory - Dummy backend that simply save exceptions in memory. Typically

used in testing environments.

heroku - In-process posting for outside of vpn apps

file - Append JSON-encoded exceptions to a file.

Returns the String backend name. See also ‘Failbot.backend`.



48
49
50
51
52
# File 'lib/failbot/compat.rb', line 48

def backend_name
  warn "#{caller[0]} Failbot.backend_name is deprecated and will be " \
    "removed in subsequent releases."
  config['backend']
end

#cast(data) ⇒ Object

Send the exception data to the relay service using a non-waiting cast call.

data - Hash of string key => string value pairs.

Returns nothing.



136
137
138
139
140
# File 'lib/failbot/compat.rb', line 136

def cast(data)
  warn "#{caller[0]} Failbot.cast is deprecated and will be " \
    "removed in subsequent releases."
  backend.report(data)
end

#configObject

Hash of configuration data from lib/failbot/failbot.yml.



24
25
26
27
28
# File 'lib/failbot/compat.rb', line 24

def config
  warn "#{caller[0]} Failbot.config is deprecated and will be " \
    "removed in subsequent releases."
  @config ||= YAML.load_file(config_file)[environment]
end

#config_fileObject

Location of failbot.yml config file.



31
32
33
34
35
# File 'lib/failbot/compat.rb', line 31

def config_file
  warn "#{caller[0]} Failbot.config_file is deprecated and will be " \
    "removed in subsequent releases."
  File.expand_path('../../failbot/failbot.yml', __FILE__)
end

#default_optionsObject



148
149
150
151
152
# File 'lib/failbot/compat.rb', line 148

def default_options
  warn "#{caller[0]} Failbot.default_options is deprecated and will be " \
    "removed in subsequent releases."
  context[0]
end

#default_options=(hash) ⇒ Object



154
155
156
157
158
# File 'lib/failbot/compat.rb', line 154

def default_options=(hash)
  warn "#{caller[0]} Failbot.default_options= is deprecated. Please use " \
    "Failbot.setup(ENV, context={}) instead."
  context[0] = hash
end

#environmentObject

The current “environment”. This dictates which section will be read from the failbot.yml config file.



17
18
19
20
21
# File 'lib/failbot/compat.rb', line 17

def environment
  warn "#{caller[0]} Failbot.environment is deprecated and will be " \
    "removed in subsequent releases."
  @environment ||= ENV['FAILBOT_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
end

#failObject



142
143
144
145
146
# File 'lib/failbot/compat.rb', line 142

def fail
  warn "#{caller[0]} Failbot.fail is deprecated and will be " \
    "removed in subsequent releases."
  raise "failure failure!"
end

#haystackObject

The URL where exceptions should be posted. Each exception is converted into JSON and posted to this URL.



124
125
126
127
128
# File 'lib/failbot/compat.rb', line 124

def haystack
  warn "#{caller[0]} Failbot.haystack is deprecated and will be " \
    "removed in subsequent releases."
  config['haystack']
end

#raise_errors=(v) ⇒ Object



71
72
73
74
75
# File 'lib/failbot/compat.rb', line 71

def raise_errors=(v)
  warn "#{caller[0]} Failbot.raise_errors= is deprecated and will be " \
    "removed in subsequent releases."
  @raise_errors = v
end

#raise_errors?Boolean

Determines whether exceptions are raised instead of being reported to the exception tracking service. This is typically enabled in development and test environments. When set true, no exception information is reported and the exception is raised instead. When false (default in production environments), the exception is reported to the exception tracking service but not raised.

Returns:

  • (Boolean)


60
61
62
63
64
65
66
67
68
69
# File 'lib/failbot/compat.rb', line 60

def raise_errors?
  warn "#{caller[0]} Failbot.raise_errors? is deprecated and will be " \
    "removed in subsequent releases."

  if @raise_errors.nil?
    config['raise_errors']
  else
    @raise_errors
  end
end

#report_errors=(v) ⇒ Object



88
89
90
91
92
# File 'lib/failbot/compat.rb', line 88

def report_errors=(v)
  warn "#{caller[0]} Failbot.report_errors= is deprecated and will be " \
    "removed in subsequent releases."
  @report_errors = v
end

#report_errors?Boolean

Returns:

  • (Boolean)


77
78
79
80
81
82
83
84
85
86
# File 'lib/failbot/compat.rb', line 77

def report_errors?
  warn "#{caller[0]} Failbot.report_errors? is deprecated and will be " \
    "removed in subsequent releases."

  if @report_errors.nil?
    config['report_errors']
  else
    @report_errors
  end
end

#setup_deprecated(_config = {}) ⇒ Object

DEPRECATED Reset the backend and optionally override the environment configuration.

config - The optional configuration Hash.

Returns nothing.



9
10
11
12
13
# File 'lib/failbot/compat.rb', line 9

def setup_deprecated(_config={})
  config.merge!(_config)
  @backend = nil
  @raise_errors = nil
end