Class: Fluent::FilterCodecOutput

Inherits:
Output
  • Object
show all
Includes:
HandleTagNameMixin
Defined in:
lib/fluent/plugin/out_filter_codec.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



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

def configure(conf)
  super

  # Put new functions here
  @codec_functions = {
    'base64-decode' => method(:base64_decode),
    'base64-encode' => method(:base64_encode)
  }

  if (field.nil? || codec.nil?) 
    raise ConfigError, "filter_codec: Both 'field', and 'codec' are required to be set."
  end

  if (@codec_functions[codec].nil?)
    raise ConfigError, "filter_codec: Unknown codec : " + codec
  end

  @field = field
  @codec = codec
  @output_field = output_field || field
  @error_value = error_value

end

#emit(tag, es, chain) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/fluent/plugin/out_filter_codec.rb', line 40

def emit(tag, es, chain)
  es.each { |time, record|
    t = tag.dup
    filter_record(t, time, record)
    Engine.emit(t, time, record)
  }

  chain.next
end

#filter_record(tag, time, record) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/fluent/plugin/out_filter_codec.rb', line 50

def filter_record(tag, time, record)
  super(tag, time, record)
  value_in = record[@field]
  if (value_in.nil?)
    return
  end

  record[@output_field] = process(value_in, @codec) || value_in
end