class Fluent::TextParser::ExtendedMultilineParser

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# 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?() click to toggle source
# File lib/fluent/plugin/parser_multiline_extended.rb, line 19
def has_splitter?
  !@splitter_regex.nil?
end
splitter(glob) click to toggle source
# 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