Class: Fluent::Plugin::MultilineGreenplumLogParser
- Inherits:
-
Parser
- Object
- Parser
- Fluent::Plugin::MultilineGreenplumLogParser
- Defined in:
- lib/fluent/plugin/parser_multiline_greenplum_log.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #firstline?(text) ⇒ Boolean
- #has_firstline? ⇒ Boolean
-
#initialize ⇒ MultilineGreenplumLogParser
constructor
A new instance of MultilineGreenplumLogParser.
- #parse(text) ⇒ Object
- #values_map(values) ⇒ Object
Constructor Details
#initialize ⇒ MultilineGreenplumLogParser
Returns a new instance of MultilineGreenplumLogParser.
25 26 27 28 |
# File 'lib/fluent/plugin/parser_multiline_greenplum_log.rb', line 25 def initialize super require 'csv' end |
Instance Method Details
#configure(conf) ⇒ Object
29 30 31 32 33 34 35 |
# 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) ⇒ Boolean
74 75 76 |
# File 'lib/fluent/plugin/parser_multiline_greenplum_log.rb', line 74 def firstline?(text) @firstline_regex.match(text) end |
#has_firstline? ⇒ Boolean
71 72 73 |
# File 'lib/fluent/plugin/parser_multiline_greenplum_log.rb', line 71 def has_firstline? !!@format_firstline end |
#parse(text) ⇒ Object
63 64 65 66 67 68 69 |
# 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) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# 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 |