lib/fluent/mixin/plaintextformatter.rb in fluent-mixin-plaintextformatter-0.2.0 vs lib/fluent/mixin/plaintextformatter.rb in fluent-mixin-plaintextformatter-0.2.1

- old
+ new

@@ -1,6 +1,7 @@ require 'fluent/config' +require 'ltsv' module Fluent module Mixin module PlainTextFormatter attr_accessor :output_include_time, :output_include_tag, :output_data_type @@ -55,19 +56,26 @@ @time_format = first_value( conf['time_format'], @time_format, nil ) @timef = @output_include_time ? Fluent::TimeFormatter.new(@time_format, @localtime) : nil @custom_attributes = if @output_data_type == 'json' nil + elsif @output_data_type == 'ltsv' + nil elsif @output_data_type =~ /^attr:(.+)$/ $1.split(',') else raise Fluent::ConfigError, "invalid output_data_type:'#{@output_data_type}'" end end def stringify_record(record) if @custom_attributes.nil? - record.to_json + case @output_data_type + when 'json' + record.to_json + when 'ltsv' + LTSV.dump(record) + end else @custom_attributes.map{|attr| (record[attr] || 'NULL').to_s }.join(@f_separator) end