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.%N %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

#acquire_worker_lock, #after_shutdown?, #after_start, #after_started?, #before_shutdown?, #called_in_test?, #closed?, #configured?, #context_router, #context_router=, #fluentd_worker_id, #get_lock_path, #has_router?, #initialize, #inspect, #multi_workers_ready?, #plugin_root_dir, #reloadable_plugin?, #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



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

def after_shutdown
  @sub_formatter.after_shutdown
  super
end

#before_shutdownObject



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

def before_shutdown
  @sub_formatter.before_shutdown
  super
end

#closeObject



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

def close
  @sub_formatter.close
  super
end

#configure(conf) ⇒ Object



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

def configure(conf)
  super

  @time_formatter = Strftime.new(@time_format || TIME_FORMAT)
  @sub_formatter = Plugin.new_formatter(@output_type, parent: self.owner)
  @sub_formatter.configure(conf)
end

#format(tag, time, record) ⇒ Object



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

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

#shutdownObject



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

def shutdown
  @sub_formatter.shutdown
  super
end

#startObject



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

def start
  super
  @sub_formatter.start
end

#stopObject



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

def stop
  @sub_formatter.stop
  super
end

#terminateObject



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

def terminate
  @sub_formatter.terminate
  super
end