class AppfluxRuby::BugfluxNotifier
Public Class Methods
notify(exception, environment = Hash.new)
click to toggle source
# 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
Private Class Methods
build_request(exception, environment)
click to toggle source
# File lib/appflux_ruby/bugflux_notifier.rb, line 32 def build_request exception, environment notice = ::AppfluxRuby::MessageBuilders::Bugflux.new(exception, environment).build request = ::Typhoeus::Request.new( ::AppfluxRuby::Bugflux.config.host, method: :post, body: notice, headers: { Accept: "application/json" } ) end
should_report_exception?()
click to toggle source
# File lib/appflux_ruby/bugflux_notifier.rb, line 42 def should_report_exception? !AppfluxRuby::Bugflux.config.ignored_environments.include?(::Rails.env) end