Class: Fluent::StdoutFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/fluent/plugin/filter_stdout.rb

Constant Summary

Constants included from Configurable

Configurable::CONFIG_TYPE_REGISTRY

Instance Attribute Summary collapse

Attributes inherited from Filter

#router

Attributes included from PluginLoggerMixin

#log

Instance Method Summary collapse

Methods inherited from Filter

#filter, #initialize, #shutdown, #start

Methods included from PluginLoggerMixin

included, #initialize

Methods included from PluginId

#plugin_id

Methods included from Configurable

#config, included, #initialize, lookup_type, register_type

Constructor Details

This class inherits a constructor from Fluent::Filter

Instance Attribute Details

#formatterObject (readonly)

for tests



25
26
27
# File 'lib/fluent/plugin/filter_stdout.rb', line 25

def formatter
  @formatter
end

Instance Method Details

#configure(conf) ⇒ Object

config_param :output_type, :string, :default => ‘json’ (StdoutFormatter defines this)



31
32
33
34
35
36
# File 'lib/fluent/plugin/filter_stdout.rb', line 31

def configure(conf)
  super

  @formatter = Plugin.new_formatter(@format)
  @formatter.configure(conf)
end

#filter_stream(tag, es) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fluent/plugin/filter_stdout.rb', line 38

def filter_stream(tag, es)
  es.each { |time, record|
    begin
      log.write @formatter.format(tag, time, record)
    rescue => e
      router.emit_error_event(tag, time, record, e)
    end
  }
  log.flush
  es
end