Parent

Methods

Included Modules

Class/Module Index [+]

Quicksearch

Fluent::TextParser::RegexpParser

Public Class Methods

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

Public Instance Methods

call(text) click to toggle source
# File lib/fluent/parser.rb, line 35
def call(text)
  m = @regexp.match(text)
  unless m
    $log.warn "pattern not match: #{text.inspect}"
    return nil, nil
  end

  time = nil
  record = {}

  m.names.each {|name|
    if value = m[name]
      case name
      when "time"
        if @time_format
          time = Time.strptime(value, @time_format).to_i
        else
          time = Time.parse(value).to_i
        end
      else
        record[name] = value
      end
    end
  }

  time ||= Engine.now

  return time, record
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.