Class: LogStash::Inputs::Stdin

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

Overview

Read events from standard input.

By default, each event is assumed to be one line. If you want to join lines, you’ll want to use the multiline codec.

Constant Summary collapse

READ_SIZE =
16384

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.reloadable?Boolean

When a configuration is using this plugin We are defining a blocking pipeline which cannot be reloaded

Returns:

  • (Boolean)


49
50
51
# File 'lib/logstash/inputs/stdin.rb', line 49

def self.reloadable?
  false
end

Instance Method Details

#registerObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/logstash/inputs/stdin.rb', line 19

def register
  begin
    @stdin = StdinChannel::Reader.new
    self.class.module_exec { alias_method :stdin_read, :channel_read }
    self.class.module_exec { alias_method :stop, :channel_stop}
  rescue => e
    @logger.debug("fallback to reading from regular $stdin", :exception => e)
    self.class.module_exec { alias_method :stdin_read, :default_read }
    self.class.module_exec { alias_method :stop, :default_stop }
  end

  @host = Socket.gethostname
  fix_streaming_codecs
end

#run(queue) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/logstash/inputs/stdin.rb', line 34

def run(queue)
  puts "The stdin plugin is now waiting for input:" if $stdin.tty?
  while !stop?
    if data = stdin_read
      @codec.decode(data) do |event|
        decorate(event)
        event.set("host", @host) if !event.include?("host")
        queue << event
      end
    end
  end
end