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.



96
97
98
# File 'lib/failbot/compat.rb', line 96

def backend
  @backend ||= backend!
end

Instance Method Details

#backend!Object



101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/failbot/compat.rb', line 101

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'])
  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.

file - Append JSON-encoded exceptions to a file.

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



46
47
48
49
50
# File 'lib/failbot/compat.rb', line 46

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.



128
129
130
131
132
# File 'lib/failbot/compat.rb', line 128

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



140
141
142
143
144
# File 'lib/failbot/compat.rb', line 140

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



146
147
148
149
150
# File 'lib/failbot/compat.rb', line 146

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



134
135
136
137
138
# File 'lib/failbot/compat.rb', line 134

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.



116
117
118
119
120
# File 'lib/failbot/compat.rb', line 116

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

#raise_errors=(v) ⇒ Object



69
70
71
72
73
# File 'lib/failbot/compat.rb', line 69

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)


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

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



86
87
88
89
90
# File 'lib/failbot/compat.rb', line 86

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)


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

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