Class: Fluent::Plugin::StdoutFormatter

Inherits:
Formatter show all
Defined in:
lib/fluent/plugin/formatter_stdout.rb

Direct Known Subclasses

Compat::TextFormatter::StdoutFormatter

Constant Summary collapse

TIME_FORMAT =
'%Y-%m-%d %H:%M:%S.%9N %z'

Constants inherited from Formatter

Formatter::PARSER_TYPES

Constants included from Configurable

Configurable::CONFIG_TYPE_REGISTRY

Instance Attribute Summary

Attributes inherited from Base

#under_plugin_development

Instance Method Summary collapse

Methods inherited from Formatter

#formatter_type

Methods included from TimeMixin::Formatter

included, #time_formatter_create

Methods included from OwnedByMixin

#log, #owner, #owner=

Methods inherited from Base

#after_shutdown?, #after_start, #after_started?, #before_shutdown?, #closed?, #configured?, #context_router, #context_router=, #fluentd_worker_id, #has_router?, #initialize, #inspect, #multi_workers_ready?, #plugin_root_dir, #shutdown?, #started?, #stopped?, #string_safe_encoding, #terminated?

Methods included from SystemConfig::Mixin

#system_config, #system_config_override

Methods included from Configurable

#config, #configure_proxy_generate, #configured_section_create, included, #initialize, lookup_type, register_type

Constructor Details

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

Instance Method Details

#after_shutdownObject



59
60
61
62
# File 'lib/fluent/plugin/formatter_stdout.rb', line 59

def after_shutdown
  @sub_formatter.after_shutdown
  super
end

#before_shutdownObject



49
50
51
52
# File 'lib/fluent/plugin/formatter_stdout.rb', line 49

def before_shutdown
  @sub_formatter.before_shutdown
  super
end

#closeObject



64
65
66
67
# File 'lib/fluent/plugin/formatter_stdout.rb', line 64

def close
  @sub_formatter.close
  super
end

#configure(conf) ⇒ Object



28
29
30
31
32
33
# File 'lib/fluent/plugin/formatter_stdout.rb', line 28

def configure(conf)
  super

  @sub_formatter = Plugin.new_formatter(@output_type, parent: self.owner)
  @sub_formatter.configure(conf)
end

#format(tag, time, record) ⇒ Object



40
41
42
# File 'lib/fluent/plugin/formatter_stdout.rb', line 40

def format(tag, time, record)
  "#{Time.at(time).localtime.strftime(TIME_FORMAT)} #{tag}: #{@sub_formatter.format(tag, time, record).chomp}\n"
end

#shutdownObject



54
55
56
57
# File 'lib/fluent/plugin/formatter_stdout.rb', line 54

def shutdown
  @sub_formatter.shutdown
  super
end

#startObject



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

def start
  super
  @sub_formatter.start
end

#stopObject



44
45
46
47
# File 'lib/fluent/plugin/formatter_stdout.rb', line 44

def stop
  @sub_formatter.stop
  super
end

#terminateObject



69
70
71
72
# File 'lib/fluent/plugin/formatter_stdout.rb', line 69

def terminate
  @sub_formatter.terminate
  super
end