Class: Adminix::Helpers::LogReader

Inherits:
EventMachine::FileTail show all
Defined in:
lib/adminix/helpers/log_reader.rb

Constant Summary

Constants inherited from EventMachine::FileTail

EventMachine::FileTail::CHUNKSIZE, EventMachine::FileTail::FORCE_ENCODING

Instance Attribute Summary

Attributes inherited from EventMachine::FileTail

#closed, #missing_file_check_interval, #path, #position, #symlink_check_interval

Instance Method Summary collapse

Methods inherited from EventMachine::FileTail

#close, #closed?, #eof, #on_exception

Constructor Details

#initialize(path, startpos = -1)) ⇒ LogReader

Returns a new instance of LogReader.



4
5
6
7
8
# File 'lib/adminix/helpers/log_reader.rb', line 4

def initialize(path, startpos=-1)
  super(path, startpos)
  Adminix.logger.info "Tailing #{path}"
  @buffer = BufferedTokenizer.new
end

Instance Method Details

#receive_data(data) ⇒ Object



10
11
12
13
# File 'lib/adminix/helpers/log_reader.rb', line 10

def receive_data(data)
  lines = @buffer.extract(data)
  Services::LogsService.add_logs(Adminix.watcher, path, lines)
end