Class: SyslogShipper::Client

Inherits:
EventMachine::FileTail
  • Object
show all
Defined in:
lib/syslog_shipper/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {:startpos => -1}) ⇒ Client

Returns a new instance of Client.



5
6
7
8
9
10
11
12
13
# File 'lib/syslog_shipper/client.rb', line 5

def initialize path, options = {:startpos => -1}
  super path, options[:startpos]
  @buffer = BufferedTokenizer.new
  @hostname = Socket.gethostname
  @connection = options[:connection]
  @raw = options[:raw]
  @ping = options[:ping]
  @verbose = options[:verbose]
end

Instance Method Details

#receive_data(data) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/syslog_shipper/client.rb', line 15

def receive_data(data)
  @buffer.extract(data).each do |line|
    if @ping
      puts 'connection successful'
      exit
    end
    
    if message = build_message(line)
      puts message if @verbose
      send_data message
    end
  end 
end