From dacbfff9ed219928857fd3d550e04c7b89a3e1ed Mon Sep 17 00:00:00 2001 From: TAGOMORI Satoshi Date: Mon, 9 May 2016 18:42:01 +0900 Subject: [PATCH] remove/merge dup code --- lib/fluent/compat/output.rb | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/fluent/compat/output.rb b/lib/fluent/compat/output.rb index 2c65807e58..362deeefd2 100644 --- a/lib/fluent/compat/output.rb +++ b/lib/fluent/compat/output.rb @@ -34,6 +34,12 @@ def self.secondary_section(conf) conf.elements.select{|e| e.name == 'secondary'}.first end + def self.inject_type_from_obsoleted_name(secconf, log) + if secconf['type'] && !secconf['@type'] + secconf['@type'] = secconf['type'] + log.warn "'type' is deprecated, and will be ignored in v1: use '@type' instead." + end + end end module BufferedEventStreamMixin @@ -220,10 +226,7 @@ def configure(conf) secconf = CompatOutputUtils.secondary_section(conf) if secconf - if secconf['type'] && !secconf['@type'] - secconf['@type'] = secconf['type'] - log.warn "'type' is deprecated, and will be ignored in v1: use '@type' instead." - end + CompatOutputUtils.inject_type_from_obsoleted_name(secconf, log) end end @@ -349,10 +352,7 @@ def configure(conf) secconf = CompatOutputUtils.secondary_section(conf) if secconf - if secconf['type'] && !secconf['@type'] - secconf['@type'] = secconf['type'] - log.warn "'type' is deprecated, and will be ignored in v1: use '@type' instead." - end + CompatOutputUtils.inject_type_from_obsoleted_name(secconf, log) end end @@ -505,10 +505,7 @@ def configure(conf) secconf = CompatOutputUtils.secondary_section(conf) if secconf - if secconf['type'] && !secconf['@type'] - secconf['@type'] = secconf['type'] - log.warn "'type' is deprecated, and will be ignored in v1: use '@type' instead." - end + CompatOutputUtils.inject_type_from_obsoleted_name(secconf, log) end end