Class: AppfluxRuby::BugfluxNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/appflux_ruby/bugflux_notifier.rb

Class Method Summary collapse

Class Method Details

.notify(exception, environment = Hash.new) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/appflux_ruby/bugflux_notifier.rb', line 14

def notify exception, environment = Hash.new
  if should_report_exception?
    ::Rails.logger.info('Notifying Appflux of this exception.')
    request = build_request(exception, environment)
    response = request.run

    unless response.code == 200
      if defined?(::Rails)
        ::Rails.logger.fatal("[Appflux-Failed] Failed to notify Appflux, please check with your configuration in config/initializers/appflux.rb. Error Code: #{ response.code }")
      else
        puts "[Appflux-Failed] Failed to notify Appflux, please check with your configuration in config/initializers/appflux.rb. Error Code: #{ response.code }"
      end
    end
  else
    ::Rails.logger.info("[Appflux] Skipping to notify Appflux for #{ ::Rails.env } environment.")
  end
end