Class: LogStash::Inputs::Stdin
- Inherits:
-
Base
- Object
- Base
- LogStash::Inputs::Stdin
- 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 filter.
Instance Method Summary collapse
Instance Method Details
#register ⇒ Object
16 17 18 19 |
# File 'lib/logstash/inputs/stdin.rb', line 16 def register @host = Socket.gethostname fix_streaming_codecs end |
#run(queue) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/logstash/inputs/stdin.rb', line 21 def run(queue) while !stop? begin # Based on some testing, there is no way to interrupt an IO.sysread nor # IO.select call in JRuby. Bummer :( data = $stdin.sysread(16384) @codec.decode(data) do |event| decorate(event) event.set("host", @host) if !event.include?("host") queue << event end rescue IOError, EOFError # stdin closed break rescue => e # ignore any exception in the shutdown process break if stop? raise(e) end end end |
#stop ⇒ Object
42 43 44 |
# File 'lib/logstash/inputs/stdin.rb', line 42 def stop $stdin.close rescue nil end |