Keep backward-compatibility
# 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
# 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
# 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