From existence TextParser pattern
From in_syslog default pattern
# File lib/fluent/parser.rb, line 552 def initialize super @mutex = Mutex.new end
# File lib/fluent/parser.rb, line 557 def configure(conf) super @time_parser_rfc3164 = @time_parser_rfc5424 = nil @regexp = case @message_format when :rfc3164 class << self alias_method :parse, :parse_plain end @with_priority ? REGEXP_WITH_PRI : REGEXP when :rfc5424 class << self alias_method :parse, :parse_plain end @time_format = @rfc5424_time_format unless conf.has_key?('time_format') @with_priority ? REGEXP_RFC5424_WITH_PRI : REGEXP_RFC5424 when :auto class << self alias_method :parse, :parse_auto end @time_parser_rfc3164 = TextParser::TimeParser.new(@time_format) @time_parser_rfc5424 = TextParser::TimeParser.new(@rfc5424_time_format) nil end @time_parser = TextParser::TimeParser.new(@time_format) end
# File lib/fluent/parser.rb, line 588 def parse(text) # This is overwritten in configure end
# File lib/fluent/parser.rb, line 592 def parse_auto(text, &block) if REGEXP_DETECT_RFC5424.match(text) @regexp = @with_priority ? REGEXP_RFC5424_WITH_PRI : REGEXP_RFC5424 @time_parser = @time_parser_rfc5424 else @regexp = @with_priority ? REGEXP_WITH_PRI : REGEXP @time_parser = @time_parser_rfc3164 end parse_plain(text, &block) end
# File lib/fluent/parser.rb, line 603 def parse_plain(text, &block) 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 "pri" record['pri'] = value.to_i when "time" time = @mutex.synchronize { @time_parser.parse(value.gsub(/ +/, ' ')) } record[name] = value if @keep_time_key else record[name] = value end end } if @estimate_current_event time ||= Engine.now end if block_given? yield time, record else return time, record end end
# File lib/fluent/parser.rb, line 584 def patterns {'format' => @regexp, 'time_format' => @time_format} end