Class: LogStash::Inputs::Internal

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/inputs/internal.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#logger

Instance Method Summary collapse

Methods inherited from Base

#tag

Constructor Details

#initialize(url, type, config = {}, &block) ⇒ Internal

Returns a new instance of Internal.



10
11
12
13
14
15
16
# 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

Instance Attribute Details

#channelObject (readonly)

Returns the value of attribute channel.



7
8
9
# File 'lib/logstash/inputs/internal.rb', line 7

def channel
  @channel
end

Instance Method Details

#receive(event) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# 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

#registerObject



19
20
21
22
23
24
# File 'lib/logstash/inputs/internal.rb', line 19

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