Class: FlumeLogger::Eventserver

Inherits:
Object
  • Object
show all
Defined in:
lib/flume-logger/eventserver.rb

Instance Method Summary collapse

Constructor Details

#initialize(host = "localhost", port = 9090, flume_type = :ng) ⇒ Eventserver

Returns a new instance of Eventserver.



2
3
4
5
6
7
# File 'lib/flume-logger/eventserver.rb', line 2

def initialize(host="localhost", port=9090, flume_type=:ng)
  @host = host
  @port = port
  @client = nil
  @type = flume_type 
end

Instance Method Details

#closeObject



22
23
24
25
26
# File 'lib/flume-logger/eventserver.rb', line 22

def close
  @client && @transport.close()
rescue => e
  warn "#{self.class} - #{e.class} - #{e.message}"
end

#write(event) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/flume-logger/eventserver.rb', line 9

def write(event)
  begin
    connect unless @client

    @client.append(event)
  rescue => e
    warn "#{self.class} - #{e.class} - #{e.message}: #{event}"
    close
    @client = nil
    raise
  end
end