Skip to content

Instantly share code, notes, and snippets.

@oogali
Created March 22, 2012 04:53
Show Gist options
  • Save oogali/2156147 to your computer and use it in GitHub Desktop.
Save oogali/2156147 to your computer and use it in GitHub Desktop.
eventmachine-tail test
#!/usr/bin/env ruby
require 'rubygems'
require 'eventmachine'
require 'eventmachine-tail'
class LogHandler < EventMachine::FileTail
def initialize(path, startpos = -1, *args)
super path, startpos
p args
@buffer = BufferedTokenizer.new
end
def receive_data(data)
puts "ENTRY"
@buffer.extract(data).each do |line|
puts line
end
puts "EXIT"
end
end
EM.run do
EventMachine::file_tail('/var/log/redis.log', LogHandler, -1, "y", "helo", "thar")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment