Class: ExceptionNotifier::HatoNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/exception_notifier/hato_notifier.rb,
lib/exception_notifier/hato_notifier/version.rb

Defined Under Namespace

Classes: ConfigurationError, Logger, Query

Constant Summary collapse

VERSION =
"0.0.3"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ HatoNotifier

Returns a new instance of HatoNotifier.

Raises:



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/exception_notifier/hato_notifier.rb', line 7

def initialize(options)
  template = options.delete(:template)
  raise ConfigurationError.new('`template` key must be set') unless template

  @tag_template     = template.delete(:tag)
  @message_template = template.delete(:message)

  if !@tag_template || !@message_template
    raise ConfigurationError.new('Both `templlate.message` and `templlate.message` keys must be set')
  end

  @logger = Logger.new(
    host:    options.delete(:host),
    port:    options.delete(:port),
    api_key: options.delete(:api_key),
  )
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



5
6
7
# File 'lib/exception_notifier/hato_notifier.rb', line 5

def logger
  @logger
end

Instance Method Details

#call(exception, options = {}) ⇒ Object



25
26
27
28
29
30
# File 'lib/exception_notifier/hato_notifier.rb', line 25

def call(exception, options = {})
  tag     = Query.build(@tag_template, exception, options)
  message = Query.build(@message_template, exception, options)

  logger.post(tag, message)
end