Class: Hatchet::AirbrakeAppender
- Inherits:
-
Object
- Object
- Hatchet::AirbrakeAppender
- Includes:
- LevelManager
- Defined in:
- lib/hatchet_airbrake/airbrake_appender.rb
Instance Attribute Summary collapse
-
#formatter ⇒ Object
Public: The formatter used to format messages before sending them to Airbrake.
-
#name ⇒ Object
Public: The name to post the messages as (default: Hatchet).
Instance Method Summary collapse
-
#add(level, context, message) ⇒ Object
Internal: Sends an error to Airbrake.
-
#initialize {|_self| ... } ⇒ AirbrakeAppender
constructor
Public: Creates a new instance.
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.
20 21 22 23 24 |
# File 'lib/hatchet_airbrake/airbrake_appender.rb', line 20 def initialize @name = 'Hatchet-Airbrake' @formatter = SimpleFormatter.new yield self if block_given? end |
Instance Attribute Details
#formatter ⇒ Object
Public: The formatter used to format messages before sending them to Airbrake
11 12 13 |
# File 'lib/hatchet_airbrake/airbrake_appender.rb', line 11 def formatter @formatter end |
#name ⇒ Object
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.
34 35 36 37 38 39 40 41 42 |
# File 'lib/hatchet_airbrake/airbrake_appender.rb', line 34 def add(level, context, ) if .error opts = { :error_message => .to_s, :backtrace => .error.backtrace } ::Airbrake.notify .error, opts end end |