class Fluent::ParserOutput

Attributes

parser[R]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_json_parser.rb, line 11
def initialize
    super
    require 'time'
end

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_json_parser.rb, line 21
def configure(conf)
    super
    if @key_name[0] == ":" 
        @key_name = @key_name[1..-1].to_sym
    end
    @parser = FluentExt::JSONParser.new(log())
end
emit(tag,es,chain) click to toggle source
# File lib/fluent/plugin/out_json_parser.rb, line 29
def emit(tag,es,chain)
    tag = @tag || tag
    es.each do |time,record|
        raw_value = record[@key_name]
        t,values = raw_value ? parse(raw_value) : [nil,nil]
        t ||= time

        r = @reserve_data ? record.merge(values) : values 
        if r
            Fluent::Engine.emit(tag,t,r)
        end
    end

    chain.next
end

Private Instance Methods

parse(string) click to toggle source
# File lib/fluent/plugin/out_json_parser.rb, line 47
def parse(string)
    return @parser.parse(string) 
end