Class: Fluent::TextParser::MultiFormatParser

Inherits:
Parser
  • Object
show all
Includes:
Configurable
Defined in:
lib/fluent/plugin/parser_multi_format.rb,
lib/fluent/plugin/parser_multi_format.rb

Overview

support old API. Will be removed.

Instance Method Summary collapse

Constructor Details

#initializeMultiFormatParser

Returns a new instance of MultiFormatParser.



9
10
11
12
13
# File 'lib/fluent/plugin/parser_multi_format.rb', line 9

def initialize
  super

  @parsers = []
end

Instance Method Details

#call(*a, &b) ⇒ Object



89
90
91
# File 'lib/fluent/plugin/parser_multi_format.rb', line 89

def call(*a, &b)
  parse(*a, &b)
end

#configure(conf) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fluent/plugin/parser_multi_format.rb', line 15

def configure(conf)
  super

  conf.elements.each { |e|
    next unless ['pattern', 'format'].include?(e.name)

    parser = Plugin.new_parser(e['format'])
    parser.configure(e)
    @parsers << parser
  }
end

#parse(text) {|nil, nil| ... } ⇒ Object

Yields:

  • (nil, nil)


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fluent/plugin/parser_multi_format.rb', line 27

def parse(text)
  @parsers.each { |parser|
    begin
      parser.parse(text) { |time, record|
        if time && record
          yield time, record
          return
        end
      }
    rescue # ignore parser error
    end
  }

  yield nil, nil
end