Class: Fluent::RecordModifierOutput

Inherits:
Output
  • Object
show all
Includes:
Mixin::ConfigPlaceholders, SetTagKeyMixin
Defined in:
lib/fluent/plugin/out_record_modifier.rb

Constant Summary collapse

BUILTIN_CONFIGURATIONS =
%W(type tag include_tag_key tag_key char_encoding)

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fluent/plugin/out_record_modifier.rb', line 15

def configure(conf)
  super

  @map = {}
  conf.each_pair { |k, v|
    unless BUILTIN_CONFIGURATIONS.include?(k)
      conf.has_key?(k)
      @map[k] = v
    end
  }

  if @char_encoding
    from, to = @char_encoding.split(':', 2)
    @from_enc = Encoding.find(from)
    @to_enc = Encoding.find(to) if to

    m = if @to_enc
          method(:convert_encoding)
        else
          method(:set_encoding)
        end

    (class << self; self; end).module_eval do
      define_method(:change_encoding, m)
    end
  end
end

#emit(tag, es, chain) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/fluent/plugin/out_record_modifier.rb', line 43

def emit(tag, es, chain)
  es.each { |time, record|
    filter_record(tag, time, record)
    Engine.emit(@tag, time, modify_record(record))
  }

  chain.next
end