Module: Failbot::Compat
- Included in:
- Failbot
- Defined in:
- lib/failbot/compat.rb
Instance Attribute Summary collapse
-
#backend ⇒ Object
Load and initialize the exception reporting backend as specified by the ‘backend’ configuration option.
Instance Method Summary collapse
- #backend! ⇒ Object
-
#backend_name ⇒ Object
The name of the backend that should be used to post exceptions to the exceptions-collection service.
-
#cast(data) ⇒ Object
Send the exception data to the relay service using a non-waiting cast call.
-
#config ⇒ Object
Hash of configuration data from lib/failbot/failbot.yml.
-
#config_file ⇒ Object
Location of failbot.yml config file.
- #default_options ⇒ Object
- #default_options=(hash) ⇒ Object
-
#environment ⇒ Object
The current “environment”.
- #fail ⇒ Object
-
#haystack ⇒ Object
The URL where exceptions should be posted.
- #raise_errors=(v) ⇒ Object
-
#raise_errors? ⇒ Boolean
Determines whether exceptions are raised instead of being reported to the exception tracking service.
- #service ⇒ Object (also: #svc)
-
#setup_deprecated(_config = {}) ⇒ Object
DEPRECATED Reset the backend and optionally override the environment configuration.
Instance Attribute Details
#backend ⇒ Object
Load and initialize the exception reporting backend as specified by the ‘backend’ configuration option.
Raises ArgumentError for invalid backends.
84 85 86 |
# File 'lib/failbot/compat.rb', line 84 def backend @backend ||= backend! end |
Instance Method Details
#backend! ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/failbot/compat.rb', line 89 def backend! warn "#{caller[0]} Failbot.backend! is deprecated and will be " \ "removed in subsequent releases." case backend_name when 'bert' url = URI("bertrpc://#{config["host"]}:#{config["port"]}") Failbot::BERTBackend.new(url) 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_name ⇒ Object
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.
bert - The BERT-RPC backend relays exceptions using the bert library.
See <https://github.com/mojombo/bert> for details.
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.
51 52 53 54 55 |
# File 'lib/failbot/compat.rb', line 51 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.
125 126 127 128 129 |
# File 'lib/failbot/compat.rb', line 125 def cast(data) warn "#{caller[0]} Failbot.cast is deprecated and will be " \ "removed in subsequent releases." backend.report(data) end |
#config ⇒ Object
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_file ⇒ Object
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.('../../failbot/failbot.yml', __FILE__) end |
#default_options ⇒ Object
145 146 147 148 149 |
# File 'lib/failbot/compat.rb', line 145 def warn "#{caller[0]} Failbot.default_options is deprecated and will be " \ "removed in subsequent releases." context[0] end |
#default_options=(hash) ⇒ Object
151 152 153 154 155 |
# File 'lib/failbot/compat.rb', line 151 def (hash) warn "#{caller[0]} Failbot.default_options= is deprecated. Please use " \ "Failbot.setup(ENV, context={}) instead." context[0] = hash end |
#environment ⇒ Object
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 |
#fail ⇒ Object
139 140 141 142 143 |
# File 'lib/failbot/compat.rb', line 139 def fail warn "#{caller[0]} Failbot.fail is deprecated and will be " \ "removed in subsequent releases." raise "failure failure!" end |
#haystack ⇒ Object
The URL where exceptions should be posted. Each exception is converted into JSON and posted to this URL.
113 114 115 116 117 |
# File 'lib/failbot/compat.rb', line 113 def haystack warn "#{caller[0]} Failbot.haystack is deprecated and will be " \ "removed in subsequent releases." config['haystack'] end |
#raise_errors=(v) ⇒ Object
74 75 76 77 78 |
# File 'lib/failbot/compat.rb', line 74 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.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/failbot/compat.rb', line 63 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 |
#service ⇒ Object Also known as: svc
131 132 133 134 135 |
# File 'lib/failbot/compat.rb', line 131 def service warn "#{caller[0]} Failbot.service is deprecated and will be " \ "removed in subsequent releases." @service ||= BERTRPC::Service.new(config['host'], config['port']) 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 |