Class: AxialNotifier::Sender

Inherits:
Object
  • Object
show all
Defined in:
lib/axial_notifier/sender.rb

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Sender

Returns a new instance of Sender.



3
4
5
6
# File 'lib/axial_notifier/sender.rb', line 3

def initialize(configuration)
  @config = configuration
  @syslog = Syslog.open(@config.api_key, nil, @config.facility)
end

Instance Method Details

#log(exception) ⇒ Object



8
9
10
# File 'lib/axial_notifier/sender.rb', line 8

def log(exception)
  @syslog.err parse(exception)
end

#parse(exception) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/axial_notifier/sender.rb', line 12

def parse(exception)
  if exception.is_a?(String)
    {:message => exception}.to_json
  else
    {
      :environment => (@config.environment),
      :exception => exception.class,
      :message => exception.message,
      :backtrace => exception.backtrace.join('\n')
    }.to_json
  end
end