Class: LogStash::Outputs::CSV

Inherits:
File
  • Object
show all
Defined in:
lib/logstash/outputs/csv.rb

Overview

CSV output.

Write events to disk in CSV or other delimited format Based on the file output, many config values are shared Uses the Ruby csv library internally

Instance Method Summary collapse

Instance Method Details

#multi_receive_encoded(events_and_encoded) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/logstash/outputs/csv.rb', line 36

def multi_receive_encoded(events_and_encoded)
  encoded_by_path = Hash.new {|h,k| h[k] = []}

  events_and_encoded.each do |event,encoded|
    file_output_path = event_path(event)
    encoded_by_path[file_output_path] << event_to_csv(event)
  end

  @io_mutex.synchronize do
    encoded_by_path.each do |path,chunks|
      fd = open(path)
      chunks.each {|chunk| fd.write(chunk) }
      fd.flush
    end

    close_stale_files
  end
end

#registerObject



30
31
32
33
# File 'lib/logstash/outputs/csv.rb', line 30

def register
  super
  @csv_options = Hash[@csv_options.map{|(k, v)|[k.to_sym, v]}]
end