Class: Fluent::Plugin::StdoutFilter

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

Constant Summary collapse

DEFAULT_FORMAT_TYPE =
'stdout'

Constants included from Configurable

Configurable::CONFIG_TYPE_REGISTRY

Instance Attribute Summary collapse

Attributes inherited from Filter

#has_filter_with_time

Attributes included from Fluent::PluginLoggerMixin

#log

Attributes inherited from Base

#under_plugin_development

Instance Method Summary collapse

Methods inherited from Filter

#filter, #filter_with_time, #initialize

Methods included from Fluent::PluginHelper::Mixin

included

Methods included from Fluent::PluginLoggerMixin

included, #initialize, #start, #terminate

Methods included from Fluent::PluginId

#plugin_id, #plugin_id_configured?, #plugin_id_for_test?

Methods inherited from Base

#after_shutdown, #after_shutdown?, #after_start, #after_started?, #before_shutdown, #before_shutdown?, #close, #closed?, #configured?, #has_router?, #initialize, #inspect, #shutdown, #shutdown?, #start, #started?, #stop, #stopped?, #terminate, #terminated?

Methods included from SystemConfig::Mixin

#system_config, #system_config_override

Methods included from Configurable

#config, included, #initialize, lookup_type, register_type

Constructor Details

This class inherits a constructor from Fluent::Plugin::Filter

Instance Attribute Details

#formatterObject (readonly)

for tests



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

def formatter
  @formatter
end

Instance Method Details

#configure(conf) ⇒ Object



34
35
36
37
38
# File 'lib/fluent/plugin/filter_stdout.rb', line 34

def configure(conf)
  compat_parameters_convert(conf, :inject, :formatter)
  super
  @formatter = formatter_create(conf: @config.elements('format').first, default_type: DEFAULT_FORMAT_TYPE)
end

#filter_stream(tag, es) ⇒ Object



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

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