Sha256: 045d21b248da7775b2b9d1a69d5d822a9864076f6bddf6755d71920b52246ee5
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
## # This class is specific only to sending bugflux notifications. It calls # +MessageBuilder+ class for building the payload message and uses SSL to send # the messages. It also implements a basic queue to send messages in batches. # This is the default behaviour. require 'typhoeus' module AppfluxRuby class BugfluxNotifier class << self 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 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 private def should_report_exception? !AppfluxRuby::Bugflux.config.ignored_environments.include?(::Rails.env) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
appflux_ruby-0.1.2 | lib/appflux_ruby/bugflux_notifier.rb |