Parent

Class/Module Index [+]

Quicksearch

Fluent::TextParser::RegexpParser

Attributes

estimate_current_event[RW]

SET false BEFORE CONFIGURE, to return nil when time not parsed ‘configure()’ may raise errors for unexpected configurations

Public Class Methods

new(regexp, conf={}) click to toggle source
# File lib/fluent/parser.rb, line 135
def initialize(regexp, conf={})
  super()
  @regexp = regexp
  unless conf.empty?
    configure(conf)
  end

  @time_parser = TimeParser.new(@time_format)
  @estimate_current_event = true
  @mutex = Mutex.new
end

Public Instance Methods

call(text) click to toggle source
# File lib/fluent/parser.rb, line 156
def call(text)
  m = @regexp.match(text)
  unless m
    if block_given?
      yield nil, nil
      return
    else
      return nil, nil
    end
  end

  time = nil
  record = {}

  m.names.each {|name|
    if value = m[name]
      case name
      when "time"
        time = @mutex.synchronize { @time_parser.parse(value) }
      else
        record[name] = if @type_converters.nil?
                         value
                       else
                         convert_type(name, value)
                       end
      end
    end
  }

  if @estimate_current_event
    time ||= Engine.now
  end

  if block_given?
    yield time, record
  else # keep backward compatibility. will be removed at v1
    return time, record
  end
end
configure(conf) click to toggle source
# File lib/fluent/parser.rb, line 147
def configure(conf)
  super
  @time_parser = TimeParser.new(@time_format)
end
patterns() click to toggle source
# File lib/fluent/parser.rb, line 152
def patterns
  {'format' => @regexp, 'time_format' => @time_format}
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.