Sha256: 98c95872bb513136ae32ff9a2bddbb2a768a92e5e241dcf1143da1215c042c55

Contents?: true

Size: 1.09 KB

Versions: 15

Compression:

Stored size: 1.09 KB

Contents

# encoding: utf-8

module FileWatch module TailMode module Handlers
  class Delete < Base
    DATA_LOSS_WARNING = "watched file path was deleted or rotated before all content was read, if the file is found again it will be read from the last position"
    def handle_specifically(watched_file)
      # TODO consider trying to find the renamed file - it will have the same inode.
      # Needs a rotate scheme rename hint from user e.g. "<name>-YYYY-MM-DD-N.<ext>" or "<name>.<ext>.N"
      # send the found content to the same listener (stream identity)
      logger.trace("info",
        "watched_file details" => watched_file.details,
        "path" => watched_file.path)
      if watched_file.bytes_unread > 0
        logger.warn(DATA_LOSS_WARNING, "unread_bytes" => watched_file.bytes_unread, "path" => watched_file.path)
      end
      watched_file.listener.deleted
      # no need to worry about data in the buffer
      # if found it will be associated by inode and read from last position
      sincedb_collection.watched_file_deleted(watched_file)
      watched_file.file_close
    end
  end
end end end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
logstash-input-file-4.1.18 lib/filewatch/tail_mode/handlers/delete.rb
logstash-input-file-4.1.17 lib/filewatch/tail_mode/handlers/delete.rb
logstash-input-file-4.1.16 lib/filewatch/tail_mode/handlers/delete.rb
logstash-input-file-4.1.15 lib/filewatch/tail_mode/handlers/delete.rb
logstash-input-file-4.1.14 lib/filewatch/tail_mode/handlers/delete.rb
logstash-input-file-4.1.13 lib/filewatch/tail_mode/handlers/delete.rb
logstash-input-file-4.1.12 lib/filewatch/tail_mode/handlers/delete.rb
logstash-input-file-4.1.11 lib/filewatch/tail_mode/handlers/delete.rb
logstash-input-file-4.1.10 lib/filewatch/tail_mode/handlers/delete.rb
logstash-input-file-4.1.9 lib/filewatch/tail_mode/handlers/delete.rb
logstash-input-file-4.1.8 lib/filewatch/tail_mode/handlers/delete.rb
logstash-input-file-4.1.7 lib/filewatch/tail_mode/handlers/delete.rb
logstash-input-file-4.1.6 lib/filewatch/tail_mode/handlers/delete.rb
logstash-input-file-4.1.5 lib/filewatch/tail_mode/handlers/delete.rb
logstash-input-file-4.1.4 lib/filewatch/tail_mode/handlers/delete.rb