Class: Fluent::TextParser::MultilineParser

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

Constant Summary collapse

FORMAT_MAX_NUM =
20

Constants included from Configurable

Configurable::CONFIG_TYPE_REGISTRY

Instance Attribute Summary

Attributes inherited from Parser

#estimate_current_event

Instance Method Summary collapse

Methods inherited from Parser

#call, #initialize

Methods included from Configurable

#config, included, #initialize, lookup_type, register_type

Constructor Details

This class inherits a constructor from Fluent::Parser

Instance Method Details

#configure(conf) ⇒ Object



603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
# File 'lib/fluent/parser.rb', line 603

def configure(conf)
  super

  formats = parse_formats(conf).compact.map { |f| f[1..-2] }.join
  begin
    @regex = Regexp.new(formats, Regexp::MULTILINE)
    if @regex.named_captures.empty?
      raise "No named captures"
    end
    @parser = RegexpParser.new(@regex, conf)
  rescue => e
    raise ConfigError, "Invalid regexp '#{formats}': #{e}"
  end

  if @format_firstline
    check_format_regexp(@format_firstline, 'format_firstline')
    @firstline_regex = Regexp.new(@format_firstline[1..-2])
  end
end

#firstline?(text) ⇒ Boolean

Returns:

  • (Boolean)


635
636
637
# File 'lib/fluent/parser.rb', line 635

def firstline?(text)
  @firstline_regex.match(text)
end

#has_firstline?Boolean

Returns:

  • (Boolean)


631
632
633
# File 'lib/fluent/parser.rb', line 631

def has_firstline?
  !!@format_firstline
end

#parse(text, &block) ⇒ Object



623
624
625
626
627
628
629
# File 'lib/fluent/parser.rb', line 623

def parse(text, &block)
  if block
    @parser.call(text, &block)
  else
    @parser.call(text)
  end
end