Class: LogStash::Outputs::Stdout

Inherits:
Base show all
Defined in:
lib/logstash/outputs/stdout.rb

Constant Summary

Constants included from Config::Mixin

Config::Mixin::CONFIGSORT

Instance Attribute Summary

Attributes included from Config::Mixin

#config, #original_params

Attributes inherited from Plugin

#logger, #params

Instance Method Summary collapse

Methods inherited from Base

#handle, #handle_worker, #initialize, #worker_setup, #workers_not_supported

Methods included from Config::Mixin

#config_init, included

Methods inherited from Plugin

#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s

Constructor Details

This class inherits a constructor from LogStash::Outputs::Base

Instance Method Details

#receive(event) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/logstash/outputs/stdout.rb', line 44

def receive(event)
  return unless output?(event)
  if event == LogStash::SHUTDOWN
    finished
    return
  end
  @codec.encode(event)
end

#registerObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/logstash/outputs/stdout.rb', line 26

def register
  if @debug
    require "logstash/codecs/rubydebug"
    require "logstash/codecs/dots"
    require "logstash/codecs/json"
    case @debug_format
      when "ruby"; @codec = LogStash::Codecs::RubyDebug.new
      when "json"; @codec = LogStash::Codecs::JSON.new
      when "dots"; @codec = LogStash::Codecs::Dots.new
    end
  elsif @message
    @codec = LogStash::Codecs::Line.new("format" => @message)
  end
  @codec.on_event do |event|
    $stdout.write(event)
  end
end