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.
1320 1321 1322 1323 1324 1325 |
# File 'lib/fluent/plugin/in_tail.rb', line 1320 def initialize(log, &on_rotate) @log = log @inode = nil @fsize = -1 # first @on_rotate = on_rotate end |
Instance Method Details
#on_notify(stat) ⇒ Object
1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 |
# File 'lib/fluent/plugin/in_tail.rb', line 1327 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 |