Class: Fluent::Plugin::TailInput::TailWatcher::RotateHandler
- Inherits:
-
Object
- Object
- Fluent::Plugin::TailInput::TailWatcher::RotateHandler
- Defined in:
- lib/fluent/plugin/in_tail.rb
Instance Method Summary collapse
-
#initialize(watcher, &on_rotate) ⇒ RotateHandler
constructor
A new instance of RotateHandler.
- #on_notify(stat) ⇒ Object
Constructor Details
#initialize(watcher, &on_rotate) ⇒ RotateHandler
Returns a new instance of RotateHandler.
736 737 738 739 740 741 |
# File 'lib/fluent/plugin/in_tail.rb', line 736 def initialize(watcher, &on_rotate) @watcher = watcher @inode = nil @fsize = -1 # first @on_rotate = on_rotate end |
Instance Method Details
#on_notify(stat) ⇒ Object
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 |
# File 'lib/fluent/plugin/in_tail.rb', line 743 def on_notify(stat) if stat.nil? inode = nil fsize = 0 else inode = stat.ino fsize = stat.size end begin if @inode != inode || fsize < @fsize @on_rotate.call(stat) end @inode = inode @fsize = fsize end rescue @watcher.log.error $!.to_s @watcher.log.error_backtrace end |