Parent

Methods

Class/Module Index [+]

Quicksearch

Fluent::TailInput::TailWatcher::RotateHandler

Public Class Methods

new(path, &on_rotate) click to toggle source
# File lib/fluent/plugin/in_tail.rb, line 356
def initialize(path, &on_rotate)
  @path = path
  @inode = nil
  @fsize = -1  # first
  @on_rotate = on_rotate
  @path = path
end

Public Instance Methods

on_notify() click to toggle source
# File lib/fluent/plugin/in_tail.rb, line 364
def on_notify
  begin
    io = File.open(@path)
    stat = io.stat
    inode = stat.ino
    fsize = stat.size
  rescue Errno::ENOENT
    # moved or deleted
    inode = nil
    fsize = 0
  end

  begin
    if @inode != inode || fsize < @fsize
      # rotated or truncated
      @on_rotate.call(io)
      io = nil
    end

    @inode = inode
    @fsize = fsize
  ensure
    io.close if io
  end

rescue
  $log.error $!.to_s
  $log.error_backtrace
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.