class LogStash::Inputs::Generator
Generate random log events.
The general intention of this is to test performance of plugins.
An event is generated first
Public Instance Methods
close()
click to toggle source
# File lib/logstash/inputs/generator.rb, line 87 def close if @codec.respond_to?(:flush) @codec.flush do |event| decorate(event) event.set("host", @host) queue << event end end end
register()
click to toggle source
# File lib/logstash/inputs/generator.rb, line 50 def register @host = Socket.gethostname @count = Array(@count).first end
run(queue)
click to toggle source
# File lib/logstash/inputs/generator.rb, line 55 def run(queue) number = 0 if @message == "stdin" @logger.info("Generator plugin reading a line from stdin") @message = $stdin.readline @logger.debug("Generator line read complete", :message => @message) end @lines = [@message] if @lines.nil? while !stop? && (@count <= 0 || number < @count) @lines.each do |line| @codec.decode(line.clone) do |event| decorate(event) event.set("host", @host) event.set("sequence", number) queue << event end end number += 1 end # loop if @codec.respond_to?(:flush) @codec.flush do |event| decorate(event) event.set("host", @host) queue << event end end end