Class: Fluent::Plugin::TailInput::TailWatcher::RotateHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/in_tail.rb

Instance Method Summary collapse

Constructor Details

#initialize(log, &on_rotate) ⇒ RotateHandler

Returns a new instance of RotateHandler.



1343
1344
1345
1346
1347
1348
# File 'lib/fluent/plugin/in_tail.rb', line 1343

def initialize(log, &on_rotate)
  @log = log
  @inode = nil
  @fsize = -1  # first
  @on_rotate = on_rotate
end

Instance Method Details

#on_notify(stat) ⇒ Object



1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
# File 'lib/fluent/plugin/in_tail.rb', line 1350

def on_notify(stat)
  if stat.nil?
    inode = nil
    fsize = 0
  else
    inode = stat.ino
    fsize = stat.size
  end

  if @inode != inode || fsize < @fsize
    @on_rotate.call(stat)
  end
  @inode = inode
  @fsize = fsize
rescue
  @log.error $!.to_s
  @log.error_backtrace
end