module Fluent::Compat::TextFormatter

def self.create(conf)

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

def self.lookup(type)

def self.lookup(type)
  # TODO: warn when deprecated to use Plugin.new_formatter(type, parent: plugin)
  Fluent::Plugin.new_formatter(type)
end

def self.register_template(type, template)

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