Class: 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.
Constant Summary
Constants included from Config::Mixin
Instance Attribute Summary
Attributes inherited from Base
Attributes included from Config::Mixin
Attributes inherited from Plugin
Instance Method Summary collapse
- #register ⇒ Object
-
#run(queue) ⇒ Object
def register.
- #teardown ⇒ Object
Methods inherited from Base
Methods included from Config::Mixin
Methods inherited from Plugin
#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #terminating?, #to_s
Constructor Details
This class inherits a constructor from LogStash::Inputs::Base
Instance Method Details
#register ⇒ Object
17 18 19 |
# File 'lib/logstash/inputs/stdin.rb', line 17 def register @host = Socket.gethostname end |
#run(queue) ⇒ Object
def register
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/logstash/inputs/stdin.rb', line 21 def run(queue) while true 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["host"] = @host queue << event end rescue EOFError, LogStash::ShutdownSignal # stdin closed or a requested shutdown break end end # while true finished end |
#teardown ⇒ Object
41 42 43 44 45 |
# File 'lib/logstash/inputs/stdin.rb', line 41 def teardown @logger.debug("stdin shutting down.") $stdin.close rescue nil finished end |