Module: ForwardAWSUtil

Included in:
Fluent::ForwardAWSInput, Fluent::ForwardAWSOutput
Defined in:
lib/fluent/plugin/forward_aws_util.rb

Class Method Summary collapse

Class Method Details

.filtertag(tag, add_prefix = nil, remove_prefix = nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fluent/plugin/forward_aws_util.rb', line 3

def self.filtertag(tag,add_prefix=nil,remove_prefix=nil)
  # Remove Prefix First
  if remove_prefix && tag
    tag = tag.sub(/^#{Regexp.escape(remove_prefix)}\b\.?/,"")
  end
  
  # Add Prefix
  if add_prefix
    if tag && tag.length > 0 
      tag = "#{add_prefix}.#{tag}"
    else
      tag = add_prefix
    end
  end
  
  # Return Result
  return tag
end