Module: Fluent::Compat::HandleTagNameMixin
- Includes:
- RecordFilterMixin
- Defined in:
- lib/fluent/compat/handle_tag_name_mixin.rb
Instance Attribute Summary collapse
-
#add_tag_prefix ⇒ Object
Returns the value of attribute add_tag_prefix.
-
#add_tag_suffix ⇒ Object
Returns the value of attribute add_tag_suffix.
-
#remove_tag_prefix ⇒ Object
Returns the value of attribute remove_tag_prefix.
-
#remove_tag_suffix ⇒ Object
Returns the value of attribute remove_tag_suffix.
Instance Method Summary collapse
Methods included from RecordFilterMixin
Instance Attribute Details
#add_tag_prefix ⇒ Object
Returns the value of attribute add_tag_prefix.
24 25 26 |
# File 'lib/fluent/compat/handle_tag_name_mixin.rb', line 24 def add_tag_prefix @add_tag_prefix end |
#add_tag_suffix ⇒ Object
Returns the value of attribute add_tag_suffix.
24 25 26 |
# File 'lib/fluent/compat/handle_tag_name_mixin.rb', line 24 def add_tag_suffix @add_tag_suffix end |
#remove_tag_prefix ⇒ Object
Returns the value of attribute remove_tag_prefix.
24 25 26 |
# File 'lib/fluent/compat/handle_tag_name_mixin.rb', line 24 def remove_tag_prefix @remove_tag_prefix end |
#remove_tag_suffix ⇒ Object
Returns the value of attribute remove_tag_suffix.
24 25 26 |
# File 'lib/fluent/compat/handle_tag_name_mixin.rb', line 24 def remove_tag_suffix @remove_tag_suffix end |
Instance Method Details
#configure(conf) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fluent/compat/handle_tag_name_mixin.rb', line 25 def configure(conf) super @remove_tag_prefix = if conf.has_key?('remove_tag_prefix') Regexp.new('^' + Regexp.escape(conf['remove_tag_prefix'])) else nil end @remove_tag_suffix = if conf.has_key?('remove_tag_suffix') Regexp.new(Regexp.escape(conf['remove_tag_suffix']) + '$') else nil end @add_tag_prefix = conf['add_tag_prefix'] @add_tag_suffix = conf['add_tag_suffix'] end |
#filter_record(tag, time, record) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/fluent/compat/handle_tag_name_mixin.rb', line 44 def filter_record(tag, time, record) tag.sub!(@remove_tag_prefix, '') if @remove_tag_prefix tag.sub!(@remove_tag_suffix, '') if @remove_tag_suffix tag.insert(0, @add_tag_prefix) if @add_tag_prefix tag << @add_tag_suffix if @add_tag_suffix super(tag, time, record) end |