Class: Hatchet::AirbrakeAppender

Inherits:
Object
  • Object
show all
Includes:
LevelManager
Defined in:
lib/hatchet_airbrake/airbrake_appender.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ AirbrakeAppender

Public: Creates a new instance.

By default the appender is created with a SimpleFormatter.

block - Optional block that can be used to customize the appender. The

appender itself is passed to the block.

Yields:

  • (_self)

Yield Parameters:



16
17
18
19
# File 'lib/hatchet_airbrake/airbrake_appender.rb', line 16

def initialize
  @name = 'Hatchet-Airbrake'
  yield self if block_given?
end

Instance Attribute Details

#nameObject

Public: The name to post the messages as (default: Hatchet).



7
8
9
# File 'lib/hatchet_airbrake/airbrake_appender.rb', line 7

def name
  @name
end

Instance Method Details

#add(level, context, message) ⇒ Object

Internal: Sends an error to Airbrake.

level - The level of the message. context - The context of the message. message - The unformatted message.

Returns nothing.



29
30
31
32
33
34
35
36
37
# File 'lib/hatchet_airbrake/airbrake_appender.rb', line 29

def add(level, context, message)
  if message.error
    opts = {
      :error_message => message.to_s,
      :backtrace => message.error.backtrace
    }
    ::Airbrake.notify message.error, opts
  end
end