class LogStash::Inputs::Internal

Attributes

channel[R]

Public Class Methods

new(url, type, config={}, &block) click to toggle source
Calls superclass method LogStash::Inputs::Base::new
# File lib/logstash/inputs/internal.rb, line 10
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

Public Instance Methods

receive(event) click to toggle source
# File lib/logstash/inputs/internal.rb, line 27
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
register() click to toggle source
# File lib/logstash/inputs/internal.rb, line 19
def register
  @logger.info("Registering input #{@url}")
  @channel.subscribe do |event|
    receive(event)
  end
end