Sha256: 1a3cb65cd075c2c7cd07126db6b413332e9e3b40c7bc91ea6869b2374827fbf2

Contents?: true

Size: 1.38 KB

Versions: 16

Compression:

Stored size: 1.38 KB

Contents

# encoding: utf-8

module LogStash module Inputs
  # As and when a new WatchedFile is processed FileWatch asks for an instance of this class for the
  # file path of that WatchedFile. All subsequent callbacks are sent via this listener instance.
  # The file is essentially a stream and the path is the identity of that stream.
  class FileListener
    attr_reader :input, :path, :data
    # construct with link back to the input plugin instance.
    def initialize(path, input)
      @path, @input = path, input
      @data = nil
    end

    def opened
    end

    def eof
    end

    def error
    end

    def timed_out
      input.codec.evict(path)
    end

    def deleted
      input.codec.evict(path)
      input.handle_deletable_path(path)
    end

    def accept(data)
      # and push transient data filled dup listener downstream
      input.log_line_received(path, data)
      input.codec.accept(dup_adding_state(data))
    end

    def process_event(event)
      event.set("[@metadata][path]", path)
      event.set("path", path) unless event.include?("path")
      input.post_process_this(event)
    end

    def add_state(data)
      @data = data
      self
    end

    private

    # duplicate and add state for downstream
    def dup_adding_state(line)
      self.class.new(path, input).add_state(line)
    end
  end

  class FlushableListener < FileListener
    attr_writer :path
  end
end end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
logstash-input-file-4.1.15 lib/logstash/inputs/file_listener.rb
logstash-input-file-4.1.14 lib/logstash/inputs/file_listener.rb
logstash-input-file-4.1.13 lib/logstash/inputs/file_listener.rb
logstash-input-file-4.1.12 lib/logstash/inputs/file_listener.rb
logstash-input-file-4.1.11 lib/logstash/inputs/file_listener.rb
logstash-input-file-4.1.10 lib/logstash/inputs/file_listener.rb
logstash-input-file-4.1.9 lib/logstash/inputs/file_listener.rb
logstash-input-file-4.1.8 lib/logstash/inputs/file_listener.rb
logstash-input-file-4.1.7 lib/logstash/inputs/file_listener.rb
logstash-input-file-4.1.6 lib/logstash/inputs/file_listener.rb
logstash-input-file-4.1.5 lib/logstash/inputs/file_listener.rb
logstash-input-file-4.1.4 lib/logstash/inputs/file_listener.rb
logstash-input-file-4.1.3 lib/logstash/inputs/file_listener.rb
logstash-input-file-4.1.2 lib/logstash/inputs/file_listener.rb
logstash-input-file-4.1.1 lib/logstash/inputs/file_listener.rb
logstash-input-file-4.1.0 lib/logstash/inputs/file_listener.rb