Sha256: df37d9d9b8e71089cac1360b443056a3811002ed5522faf8b4c5efa4eeadb6a5

Contents?: true

Size: 404 Bytes

Versions: 23

Compression:

Stored size: 404 Bytes

Contents

def tail(log_file)
  cursor = File.size(log_file)
  last_checked = Time.now
  tail_thread = Thread.new do
    File.open(log_file, 'r') do |f|
      loop do
        f.seek cursor
        if f.mtime > last_checked
          last_checked = f.mtime
          contents = f.read
          cursor += contents.length
          print contents
        end
        sleep 1
      end
    end
  end
  tail_thread
end

Version data entries

23 entries across 23 versions & 5 rubygems

Version Path
rails-1.2.6 lib/commands/servers/base.rb
rq-3.3.0 rails/vendor/rails/railties/lib/commands/servers/base.rb
rq-3.4.0 rails/vendor/rails/railties/lib/commands/servers/base.rb