Sha256: 8f4b778ef376bb9cf3c7c37e9a272a83e884bebe8ec5299f2e1ea7b708ff7db3

Contents?: true

Size: 885 Bytes

Versions: 11

Compression:

Stored size: 885 Bytes

Contents

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

class LogStash::Inputs::Internal < LogStash::Inputs::Base
  attr_reader :channel

  def initialize(url, type, config={}, &block)
    super

    # Default host to the machine's hostname if it's not set
    @url.host ||= Socket.gethostname
    @channel = EventMachine::Channel.new
  end

  def register
    @logger.info("Registering input #{@url}")
    @channel.subscribe do |event|
      receive(event)
    end
  end # def register

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
logstash-lite-0.2.20101222161646 lib/logstash/inputs/internal.rb
logstash-lite-0.2.20101208111718 lib/logstash/inputs/internal.rb
logstash-lite-0.2.20101207114354 lib/logstash/inputs/internal.rb
logstash-lite-0.2.20101201111523 lib/logstash/inputs/internal.rb
logstash-lite-0.2.20101129210156 lib/logstash/inputs/internal.rb
logstash-lite-0.2.20101129205551 lib/logstash/inputs/internal.rb
logstash-lite-0.2.20101129155412 lib/logstash/inputs/internal.rb
logstash-lite-0.2.20101124030048 lib/logstash/inputs/internal.rb
logstash-lite-0.2.20101124004656 lib/logstash/inputs/internal.rb
logstash-lite-0.2.20101123134625 lib/logstash/inputs/internal.rb
logstash-lite-0.2.20101123133737 lib/logstash/inputs/internal.rb