Class: Fluent::Compat::ExecUtil::TextParserWrapperParser

Inherits:
Parser
  • Object
show all
Defined in:
lib/fluent/compat/exec_util.rb

Instance Method Summary collapse

Constructor Details

#initialize(conf, on_message) ⇒ TextParserWrapperParser

Returns a new instance of TextParserWrapperParser.



40
41
42
43
44
# File 'lib/fluent/compat/exec_util.rb', line 40

def initialize(conf, on_message)
  @parser = Plugin.new_parser(conf['format'])
  @parser.configure(conf)
  super(on_message)
end

Instance Method Details

#call(io) ⇒ Object



46
47
48
# File 'lib/fluent/compat/exec_util.rb', line 46

def call(io)
  io.each_line(&method(:each_line))
end

#each_line(line) ⇒ Object



50
51
52
53
54
55
# File 'lib/fluent/compat/exec_util.rb', line 50

def each_line(line)
  line.chomp!
  @parser.parse(line) { |time, record|
    @on_message.call(record, time)
  }
end