Class: LogStash::Outputs::Xls

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/outputs/xls.rb

Overview

A null output. This is useful for testing logstash inputs and filters for performance.

Instance Method Summary collapse

Instance Method Details

#flush(path) ⇒ Object



91
92
93
94
95
96
97
# File 'lib/logstash/outputs/xls.rb', line 91

def flush(path)
  @files.each do |path, workbook|
    if(File.basename(path) == File.basename(path))
      workbook.write path
    end
  end
end

#receive(event) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/logstash/outputs/xls.rb', line 68

def receive(event)
  @codec.encode(event)

  if event.include? "tags" and event["tags"].include?("eof")
      flush event['path']
  end
end

#registerObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/logstash/outputs/xls.rb', line 32

def register
	@files = {}

  @codec.on_event do |event|
    if @path
      path = event.sprintf(@path)
    else
      path = event["path"]
    end

   workbook = open(path)

   if event.is_a? LogStash::Event and @message_format
     output = event.sprintf(@message_format)
   else
     output = event["message"]
   end

   cells = output.split(/;/)

   wsname = event["wsname"]

   if(workbook.worksheet(wsname).nil?)
     sheet = workbook.create_worksheet :name => wsname
   else
     sheet = workbook.worksheet wsname
   end

   row_index = sheet.row_count == 0 ? 0 : sheet.last_row_index + 1
   cells.each do |cell|
     sheet.row(row_index).push cell
   end
  end
end