class ExceptionNotifier::HatoNotifier

Constants

VERSION

Attributes

logger[R]

Public Class Methods

new(options) click to toggle source
# 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

Public Instance Methods

call(exception, options = {}) click to toggle source
# 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