Created
March 22, 2012 04:53
-
-
Save oogali/2156147 to your computer and use it in GitHub Desktop.
eventmachine-tail test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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