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(log, &on_rotate) ⇒ RotateHandler
constructor
A new instance of RotateHandler.
- #on_notify(stat) ⇒ Object
Constructor Details
#initialize(log, &on_rotate) ⇒ RotateHandler
Returns a new instance of RotateHandler.
1212 1213 1214 1215 1216 1217 |
# File 'lib/fluent/plugin/in_tail.rb', line 1212 def initialize(log, &on_rotate) @log = log @inode = nil @fsize = -1 # first @on_rotate = on_rotate end |
Instance Method Details
#on_notify(stat) ⇒ Object
1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 |
# File 'lib/fluent/plugin/in_tail.rb', line 1219 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 |