Method: Fluent::Plugin.register_formatter

Defined in:
lib/fluent/plugin.rb

.register_formatter(type, klass_or_proc) ⇒ Object



77
78
79
80
81
82
83
84
85
# File 'lib/fluent/plugin.rb', line 77

def self.register_formatter(type, klass_or_proc)
  if klass_or_proc.respond_to?(:call) && klass_or_proc.arity == 3 # Proc.new { |tag, time, record| }
    # This usage is not recommended for new API
    require 'fluent/formatter'
    register_impl('formatter', FORMATTER_REGISTRY, type, Proc.new { Fluent::TextFormatter::ProcWrappedFormatter.new(klass_or_proc) })
  else
    register_impl('formatter', FORMATTER_REGISTRY, type, klass_or_proc)
  end
end