# File lib/mongrel_console/console.rb, line 22 def tail(file="log/#{@env}.log") STDERR.puts "Tailing #{file}. CTRL-C to stop it." cursor = File.size(file) last_checked = Time.now tail_thread = Thread.new do File.open(file, 'r') do |f| loop do if f.mtime > last_checked f.seek cursor last_checked = f.mtime contents = f.read cursor += contents.length print contents end sleep 1 end end end trap("INT") { tail_thread.kill } tail_thread.join nil end