Class: LogStash::Inputs::Internal
- Defined in:
- lib/logstash/inputs/internal.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(url, type, config = {}, &block) ⇒ Internal
constructor
A new instance of Internal.
- #receive(event) ⇒ Object
- #register ⇒ Object
Methods inherited from Base
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
#channel ⇒ Object (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 |
#register ⇒ Object
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 |