Sha256: d3a1201b527fbc679cfa409269edadfd5b1b9245dabd64800ed9bc3b822cfd97

Contents?: true

Size: 962 Bytes

Versions: 1

Compression:

Stored size: 962 Bytes

Contents

require 'fluent/plugin/in_tail'

class Fluent::NewTailPathInput < Fluent::NewTailInput
  class RouterWrap
    attr_accessor :tail_watcher

    def initialize(router, path_key)
      @router = router
      @path_key = path_key
      @tail_watcher = nil
    end

    def emit(tag, time, record)
      record[@path_key] = @tail_watcher.path unless @path_key.nil?
      @router.emit(tag, time, record)
    end

    def emit_array(tag, array)
      @router.emit_array(tag, array)
    end

    def emit_stream(tag, es)
      es.each {|time,record|
        record[@path_key] = @tail_watcher.path unless @path_key.nil?
      }
      @router.emit_stream(tag, es)
    end
  end

  Fluent::Plugin.register_input('tail_path', self)

  config_param :path_key, :string, :default => nil

  def configure(conf)
    super
    @router = RouterWrap.new(@router, @path_key)
  end

  def receive_lines(lines, tail_watcher)
    @router.tail_watcher = tail_watcher
    super
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-tail_path-0.1.0 lib/fluent/plugin/in_tail_path.rb