Class: Fluent::NewTailInput::TailWatcher::RotateHandler
- Inherits:
-
Object
- Object
- Fluent::NewTailInput::TailWatcher::RotateHandler
- Defined in:
- lib/fluent/plugin/in_tail.rb
Instance Method Summary collapse
-
#initialize(path, log, &on_rotate) ⇒ RotateHandler
constructor
A new instance of RotateHandler.
- #on_notify ⇒ Object
Constructor Details
#initialize(path, log, &on_rotate) ⇒ RotateHandler
Returns a new instance of RotateHandler.
631 632 633 634 635 636 637 |
# File 'lib/fluent/plugin/in_tail.rb', line 631 def initialize(path, log, &on_rotate) @path = path @inode = nil @fsize = -1 # first @on_rotate = on_rotate @log = log end |
Instance Method Details
#on_notify ⇒ Object
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 |
# File 'lib/fluent/plugin/in_tail.rb', line 639 def on_notify begin stat = File.stat(@path) 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 begin io = File.open(@path) rescue Errno::ENOENT end @on_rotate.call(io) end @inode = inode @fsize = fsize end rescue @log.error $!.to_s @log.error_backtrace end |