Class: Fluent::TextParser::ExtendedMultilineParser

Inherits:
MultilineParser
  • Object
show all
Defined in:
lib/fluent/plugin/parser_multiline_extended.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



12
13
14
15
16
17
# File 'lib/fluent/plugin/parser_multiline_extended.rb', line 12

def configure(conf)
  @splitter_regex = conf.delete('splitter_regex')
  @splitter_regex = Regexp.new(@splitter_regex[1..-2], Regexp::MULTILINE) unless @splitter_regex.nil?
  @splitter_matches = conf.delete('splitter_matches')
  super(conf)
end

#has_splitter?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/fluent/plugin/parser_multiline_extended.rb', line 19

def has_splitter?
  !@splitter_regex.nil?
end

#splitter(glob) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fluent/plugin/parser_multiline_extended.rb', line 23

def splitter(glob)
  events = []
  saved = ''
  remainder = glob
  matched = ''

  until matched.empty? and glob.empty? do
    chunk, matched, glob = glob.partition(@splitter_regex)

    if not matched.empty?
      if @splitter_matches and @splitter_matches == 'head'
        events << saved + chunk unless saved.empty? and chunk.empty?
        saved = matched
        remainder = matched + glob
      elsif @splitter_matches and @splitter_matches == 'tail'
        events << chunk + matched
        remainder = glob
      else
        events << chunk
        remainder = glob
      end
    end
      
  end

  events << remainder
  return events

end