Search this site





New eventmachine-tail features

I added block support to EM::file_tail in the eventmachine-tail gem. This lets you give a handler to the tail instead of a class, which could mean less code to write for the common case (handle lines of input):
require "rubygems"
require "eventmachine-tail"

def main(args)
  if args.length == 0
    puts "Usage: #{$0} <path> [path2] [...]"
    return 1
  end do
    args.each do |path|
      EventMachine::file_tail(path) do |filetail, line|
        # filetail is the 'EventMachine::FileTail' instance for this file.
        # line is the line read from thefile.
        # this block is invoked for every line read.
        puts line
  end #
end # def main

You can use gem to install the latest eventmachine-tail.

You can also pull the latest from github

New project: eventmachine-tail

Logstash uses EventMachine, which is an event-driven library for Ruby. Part of logstash's requirements is the ability to watch logfiles like 'tail -f' would. Previously, I was using File::Tail, but this was not EventMachine friendly.

Additionally, it's pretty common for applications to write to files with generated names that include timestamps, etc, so it was clear logstash would need a way to watch a pattern of files, like a glob such as /var/log/*.log

Thus was born eventmachine-tail.

You can install it with:

gem install eventmachine-tail
And try the 'rtail' tool that comes with it:
rtail -x "*.gz" "/var/log/**/*"
The project is hosted on github: jordansissel/eventmachine-tail.

This is the first project I've tried to use git with. I'm not really happy with git as it only seems to complicate my workflow, but I'll try to stick with it.