module Fluent::TextFormatter

Constants

TEMPLATE_REGISTRY

Public Class Methods

create(conf) click to toggle source

Keep backward-compatibility

# File lib/fluent/formatter.rb, line 299
def self.create(conf)
  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(format) click to toggle source
# File lib/fluent/formatter.rb, line 294
def self.lookup(format)
  TEMPLATE_REGISTRY.lookup(format).call
end
register_template(name, factory_or_proc) click to toggle source
# File lib/fluent/formatter.rb, line 282
def self.register_template(name, factory_or_proc)
  factory = if factory_or_proc.is_a?(Class) # XXXFormatter
              Proc.new { factory_or_proc.new }
            elsif factory_or_proc.arity == 3 # Proc.new { |tag, time, record| }
              Proc.new { ProcWrappedFormatter.new(factory_or_proc) }
            else # Proc.new { XXXFormatter.new }
              factory_or_proc
            end

  TEMPLATE_REGISTRY.register(name, factory)
end