Sha256: 9a7b39b6027df4feb4c03a1aff988cb7e237dffadaf654c44fc03c8bffc19bb5

Contents?: true

Size: 1.15 KB

Versions: 7

Compression:

Stored size: 1.15 KB

Contents

# Send a notice to Airbrake (http://airbrake.io/).
#
# apikey - The String API key.

CONTACT_DEPS[:airbrake] = ['airbrake']
CONTACT_DEPS[:airbrake].each do |d|
  require d
end

module God
  module Contacts
    class Airbrake < Contact

      class << self
        attr_accessor :apikey
      end

      def valid?
        valid = true
        valid &= complain("Attribute 'apikey' must be specified", self) if self.apikey.nil?
        valid
      end

      attr_accessor :apikey

      def notify(message, time, priority, category, host)
        ::Airbrake.configure {}

        message = "God: #{message.to_s} at #{host}"
        message << " | #{[category, priority].join(" ")}" unless category.to_s.empty? or priority.to_s.empty?

        if ::Airbrake.notify nil, :error_message => message, :api_key => arg(:apikey)
          self.info = "sent airbrake notification to #{self.name}"
        else
          self.info = "failed to send airbrake notification to #{self.name}"
        end
      rescue Object => e
        applog(nil, :info, "failed to send airbrake notification: #{e.message}")
        applog(nil, :debug, e.backtrace.join("\n"))
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
resurrected_god-0.14.0 lib/god/contacts/airbrake.rb
mcproc-2016.2.20 lib/god/contacts/airbrake.rb
god-0.13.7 lib/god/contacts/airbrake.rb
god-0.13.6 lib/god/contacts/airbrake.rb
god-0.13.5 lib/god/contacts/airbrake.rb
god-0.13.4 lib/god/contacts/airbrake.rb
god-0.13.3 lib/god/contacts/airbrake.rb