Module: Fluent::Compat::TextFormatter
- Defined in:
- lib/fluent/compat/formatter.rb
Defined Under Namespace
Classes: CsvFormatter, HashFormatter, JSONFormatter, LabeledTSVFormatter, MessagePackFormatter, OutFileFormatter, ProcWrappedFormatter, SingleValueFormatter, StdoutFormatter
Constant Summary collapse
- HandleTagAndTimeMixin =
Fluent::Compat::HandleTagAndTimeMixin
- StructuredFormatMixin =
Fluent::Compat::StructuredFormatMixin
Class Method Summary collapse
-
.create(conf) ⇒ Object
Keep backward-compatibility.
- .lookup(type) ⇒ Object
- .register_template(type, template) ⇒ Object
Class Method Details
.create(conf) ⇒ Object
Keep backward-compatibility
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fluent/compat/formatter.rb', line 57 def self.create(conf) # TODO: warn when deprecated format = conf['format'] if format.nil? raise ConfigError, "'format' parameter is required" end formatter = lookup(format) if formatter.respond_to?(:configure) formatter.configure(conf) end formatter end |
.lookup(type) ⇒ Object
51 52 53 54 |
# File 'lib/fluent/compat/formatter.rb', line 51 def self.lookup(type) # TODO: warn when deprecated to use Plugin.new_formatter(type, parent: plugin) Fluent::Plugin.new_formatter(type) end |
.register_template(type, template) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fluent/compat/formatter.rb', line 38 def self.register_template(type, template) # TODO: warn when deprecated to use Plugin.register_formatter directly if template.is_a?(Class) Fluent::Plugin.register_formatter(type, template) elsif template.respond_to?(:call) && template.arity == 3 # Proc.new { |tag, time, record| } Fluent::Plugin.register_formatter(type, Proc.new { ProcWrappedFormatter.new(template) }) elsif template.respond_to?(:call) Fluent::Plugin.register_formatter(type, template) else raise ArgumentError, "Template for formatter must be a Class or callable object" end end |