class Fluent::TextParser::WithExtraFieldsParser
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/parser_with_extra_fields.rb, line 12 def initialize super @parser = nil @extra_fields = {} end
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/parser_with_extra_fields.rb, line 18 def configure(conf) super @parser = Plugin.new_parser(@base_format) @parser.configure(conf) JSON.parse(conf["extra_fields"]).each { |k, v| @extra_fields[k] = v } end
parse(text) { |time, record| ... }
click to toggle source
# File lib/fluent/plugin/parser_with_extra_fields.rb, line 28 def parse(text) begin @parser.parse(text) { |time, record| if time && record @extra_fields.each { |k, v| record[k] = v } yield time, record return end } rescue => e $log.warn "parse failed #{e.message}" unless @suppress_parse_error_log end yield nil, nil end