class Fluent::Plugin::MultilineGreenplumLogParser
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/parser_multiline_greenplum_log.rb, line 25 def initialize super require 'csv' end
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/parser_multiline_greenplum_log.rb, line 29 def configure(conf) super if @format_firstline check_format_regexp(@format_firstline, 'format_firstline') @firstline_regex = Regexp.new(@format_firstline[1..-2]) end end
firstline?(text)
click to toggle source
# File lib/fluent/plugin/parser_multiline_greenplum_log.rb, line 74 def firstline?(text) @firstline_regex.match(text) end
has_firstline?()
click to toggle source
# File lib/fluent/plugin/parser_multiline_greenplum_log.rb, line 71 def has_firstline? !!@format_firstline end
parse(text) { |values_map(parse_line)| ... }
click to toggle source
# File lib/fluent/plugin/parser_multiline_greenplum_log.rb, line 63 def parse(text) if block_given? yield values_map(CSV.parse_line(text)) else return values_map(CSV.parse_line(text)) end end
values_map(values)
click to toggle source
# File lib/fluent/plugin/parser_multiline_greenplum_log.rb, line 37 def values_map(values) record = Hash[keys.zip(values.map { |value| convert_value_to_nil(value) })] if @time_key value = @keep_time_key ? record[@time_key] : record.delete(@time_key) time = if value.nil? if @estimate_current_event Fluent::EventTime.now else nil end else @mutex.synchronize { @time_parser.parse(value) } end elsif @estimate_current_event time = Fluent::EventTime.now else time = nil end convert_field_type!(record) if @type_converters return time, record end
Private Instance Methods
check_format_regexp(format, key)
click to toggle source
# File lib/fluent/plugin/parser_multiline_greenplum_log.rb, line 78 def check_format_regexp(format, key) if format[0] == '/' && format[-1] == '/' begin Regexp.new(format[1..-2]) rescue => e raise ConfigError, "Invalid regexp in #{key}: #{e}" end else raise ConfigError, "format_firstline should be Regexp, need //: '#{format}'" end end
convert_field_type!(record)
click to toggle source
# File lib/fluent/plugin/parser_multiline_greenplum_log.rb, line 90 def convert_field_type!(record) @type_converters.each_key { |key| if value = record[key] record[key] = convert_type(key, value) end } end
convert_value_to_nil(value)
click to toggle source
# File lib/fluent/plugin/parser_multiline_greenplum_log.rb, line 98 def convert_value_to_nil(value) if value and @null_empty_string value = (value == '') ? nil : value end if value and @null_value_pattern value = ::Fluent::StringUtil.match_regexp(@null_value_pattern, value) ? nil : value end value end