class Fluent::TextParser::RegexpParser
Public Class Methods
new(regexp, conf={})
click to toggle source
Calls superclass method
Fluent::Parser.new
# File lib/fluent/parser.rb, line 168 def initialize(regexp, conf={}) super() @regexp = regexp unless conf.empty? conf = Config::Element.new('default_regexp_conf', '', conf, []) configure(conf) end @time_parser = TimeParser.new(@time_format) @mutex = Mutex.new end
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
Fluent::TextParser::TypeConverter#configure
# File lib/fluent/parser.rb, line 180 def configure(conf) super @time_parser = TimeParser.new(@time_format) end
parse(text) { |nil, nil| ... }
click to toggle source
# File lib/fluent/parser.rb, line 189 def parse(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_key time = @mutex.synchronize { @time_parser.parse(value) } if @keep_time_key record[name] = if @type_converters.nil? value else convert_type(name, value) end end 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
patterns()
click to toggle source
# File lib/fluent/parser.rb, line 185 def patterns {'format' => @regexp, 'time_format' => @time_format} end