class LogStash::Outputs::Xlsx
A null output. This is useful for testing logstash inputs and filters for performance.
Public Instance Methods
flush(path)
click to toggle source
# File lib/logstash/outputs/xlsx.rb, line 83 def flush(path) @files.each do |path, package| if(File.basename(path) == File.basename(path)) package.serialize(path) end end end
receive(event)
click to toggle source
# File lib/logstash/outputs/xlsx.rb, line 60 def receive(event) @codec.encode(event) if event.include? "tags" and event["tags"].include?("eof") flush event['path'] end end
register()
click to toggle source
# File lib/logstash/outputs/xlsx.rb, line 33 def register @files = {} @codec.on_event do |event| if @path path = event.sprintf(@path) else path = event["path"] end 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"] worksheet = get_worksheet(path, wsname) worksheet.add_row cells end end
Private Instance Methods
get_worksheet(path, wsname)
click to toggle source
# File lib/logstash/outputs/xlsx.rb, line 92 def get_worksheet(path, wsname) package = open(path) worksheet = package.workbook.sheet_by_name(wsname) if(worksheet.nil?) package.workbook.add_worksheet(:name => wsname) do |ws| return ws end else return worksheet end end
open(path)
click to toggle source
# File lib/logstash/outputs/xlsx.rb, line 69 def open(path) return @files[path] if @files.include?(path) and not @files[path].nil? @logger.info("Opening file", :path => path) dir = File.dirname(path) if !Dir.exists?(dir) @logger.info("Creating directory", :directory => dir) FileUtils.mkdir_p(dir) end package = Axlsx::Package.new @files[path] = package end