Class: Fluent::URIDecoder
- Inherits:
-
Output
- Object
- Output
- Fluent::URIDecoder
- Defined in:
- lib/fluent/plugin/out_uri_decode.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #emit(tag, es, chain) ⇒ Object
-
#initialize ⇒ URIDecoder
constructor
A new instance of URIDecoder.
- #tag_mangle(tag) ⇒ Object
Constructor Details
#initialize ⇒ URIDecoder
Returns a new instance of URIDecoder.
10 11 12 13 |
# File 'lib/fluent/plugin/out_uri_decode.rb', line 10 def initialize super require 'uri' end |
Instance Method Details
#configure(conf) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fluent/plugin/out_uri_decode.rb', line 15 def configure(conf) super if !@remove_prefix && !@add_prefix && !@tag raise Fluent::ConfigError, "missing both of remove_prefix and add_prefix" end if @tag && @remove_prefix && @add_prefix raise Fluent::ConfigError, "either remove_prefix/add_prefix must not be specified" end if @remove_prefix @removed_prefix_string = @remove_prefix + '.' @removed_length = @removed_prefix_string.length end if @add_prefix @added_prefix_string = @add_prefix + '.' end end |
#emit(tag, es, chain) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fluent/plugin/out_uri_decode.rb', line 53 def emit(tag, es, chain) tag = tag_mangle(tag) @_key_names ||= @key_names.split(/,\s*/) @_key_names << @key_name if @key_name @_key_names.uniq! es.each do |time, record| @_key_names.each do |key_name| record[key_name] = URI.decode_www_form_component(record[key_name] || '') end router.emit(tag, time, record) end chain.next end |
#tag_mangle(tag) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fluent/plugin/out_uri_decode.rb', line 33 def tag_mangle(tag) if @tag @tag else if @remove_prefix and (tag == @remove_prefix || tag.start_with?(@removed_prefix_string) && tag.length > @removed_length) tag = tag[@removed_length..-1] end if @add_prefix tag = if tag and tag.length > 0 @added_prefix_string + tag else @add_prefix end end tag end end |