Class: ExceptionNotifier::HatoNotifier::Logger

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

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ Logger

Returns a new instance of Logger.



36
37
38
39
40
# File 'lib/exception_notifier/hato_notifier.rb', line 36

def initialize(settings)
  @host    = settings.delete(:host)
  @port    = settings.delete(:port) || 9699
  @api_key = settings.delete(:api_key)
end

Instance Method Details

#post(tag, message) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/exception_notifier/hato_notifier.rb', line 42

def post(tag, message)
  client = Net::HTTP.new(@host, @port)
  req    = Net::HTTP::Post.new('/notify')

  form_data = { 'tag' => tag, 'message' => message }
  form_data.merge!('api_key' => @api_key) if @api_key
  req.set_form_data(form_data)

  client.request(req)
end