Class: Fluent::RewriteImageOutput

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

Instance Method Summary collapse

Constructor Details

#initializeRewriteImageOutput

Returns a new instance of RewriteImageOutput.



10
11
12
# File 'lib/fluent/plugin/out_rewriteimage.rb', line 10

def initialize
  super
end

Instance Method Details

#configure(conf) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fluent/plugin/out_rewriteimage.rb', line 18

def configure(conf)
  super

  if (
      !remove_tag_prefix &&
      !remove_tag_suffix &&
      !add_tag_prefix    &&
      !add_tag_suffix
  )
    raise ConfigError, "out_rewriteimage: At least one of remove_tag_prefix/remove_tag_suffix/add_tag_prefix/add_tag_suffix is required to be set."
  end
end

#emit(tag, es, chain) ⇒ Object



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

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



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

def filter_record(tag, time, record)
  raw_media = open(record[@image_source_key], 'rb').read
    
  record[@image_key] = @base64encode ? Base64.encode64(raw_media) : raw_media

  super(tag, time, record)
end

#shutdownObject



36
37
38
39
# File 'lib/fluent/plugin/out_rewriteimage.rb', line 36

def shutdown
  super

end

#startObject



31
32
33
34
# File 'lib/fluent/plugin/out_rewriteimage.rb', line 31

def start
  super

end