class Fluent::Plugin::CsvFormatter

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method Fluent::Plugin::Base#configure
# File lib/fluent/plugin/formatter_csv.rb, line 34
def configure(conf)
  super
  @fields = fields.select{|f| !f.empty? }
  raise ConfigError, "empty value is specified in fields parameter" if @fields.empty?

  @generate_opts = {col_sep: @delimiter, force_quotes: @force_quotes}
end
format(tag, time, record) click to toggle source
# File lib/fluent/plugin/formatter_csv.rb, line 42
def format(tag, time, record)
  row = @fields.map do |key|
    record[key]
  end
  line = CSV.generate_line(row, @generate_opts)
  line.chomp! unless @add_newline
  line
end