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.
Constant Summary collapse
- READ_SIZE =
16384
Instance Method Summary collapse
Instance Method Details
#register ⇒ Object
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 |
# File 'lib/logstash/inputs/stdin.rb', line 34 def run(queue) 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 |