Sha256: edaefb28a0df75992d74e01d75e65980f4de528deab36d61ce8a184556e146ad

Contents?: true

Size: 946 Bytes

Versions: 9

Compression:

Stored size: 946 Bytes

Contents

require "eventmachine-tail"
require "logstash/inputs/base"
require "logstash/namespace"
require "socket" # for Socket.gethostname

class LogStash::Inputs::Stdin < LogStash::Inputs::Base
  public
  def register
    EventMachine::attach($stdin, InputHandler, self)
    @url.host = Socket.gethostname
  end # def register

  public
  def receive(event)
    event = LogStash::Event.new({
      "@message" => event,
      "@type" => @type,
      "@tags" => @tags.clone,
    })
    event.source = @url
    @logger.debug(["Got event", event])
    @callback.call(event)
  end # def receive

  class InputHandler < EventMachine::Connection
    def initialize(obj)
      @receiver = obj
    end # def initialize

    def receive_data(data)
      @buffer ||= BufferedTokenizer.new
      @buffer.extract(data).each do |line|
        @receiver.receive(line)
      end
    end # def receive_data
  end # class InputHandler

end # class LogStash::Inputs::Stdin

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
logstash-lite-0.2.20110505142231 lib/logstash/inputs/stdin.rb
logstash-lite-0.2.20110422152244 lib/logstash/inputs/stdin.rb
logstash-lite-0.2.20110405105201 lib/logstash/inputs/stdin.rb
logstash-lite-0.2.20110331121236 lib/logstash/inputs/stdin.rb
logstash-lite-0.2.20110329105411 lib/logstash/inputs/stdin.rb
logstash-lite-0.2.20110206003603 lib/logstash/inputs/stdin.rb
logstash-lite-0.2.20110203130400 lib/logstash/inputs/stdin.rb
logstash-lite-0.2.20110122143801 lib/logstash/inputs/stdin.rb
logstash-lite-0.2.20110112115019 lib/logstash/inputs/stdin.rb