lib/fluent/plugin/out_map.rb in fluent-plugin-map-0.1.3 vs lib/fluent/plugin/out_map.rb in fluent-plugin-map-0.2.0
- old
+ new
@@ -12,40 +12,34 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'fluent/output'
+require 'fluent/plugin/output'
require 'fluent/plugin/map_support'
require 'fluent/plugin/map_config_param'
require 'fluent/plugin/parse_map_mixin'
-module Fluent
- class MapOutput < Fluent::Output
+module Fluent::Plugin
+ class MapOutput < Fluent::Plugin::Output
Fluent::Plugin.register_output('map', self)
- include Fluent::MapConfigParam
+ helpers :event_emitter
+
+ include Fluent::Plugin::MapConfigParam
include Fluent::ParseMap::Mixin
- # Define `router` method of v0.12 to support v0.10 or earlier
- unless method_defined?(:router)
- define_method("router") { Fluent::Engine }
- end
-
- unless method_defined?(:log)
- define_method("log") { $log }
- end
-
config_param :key, :string, :default => nil #deprecated
config_param :tag, :string, :default => nil
def configure(conf)
+ log.warn "out_map is now deprecated. It will be removed in a future release. Please consider to use filter_map."
super
@format = determine_format()
configure_format()
@map = create_map(conf)
- @map_support = Fluent::MapSupport.new(@map, self)
+ @map_support = Fluent::Plugin::MapSupport.new(@map, self)
end
def determine_format()
if @format
@format
@@ -82,19 +76,17 @@
when "multimap"
parse_multimap(conf)
end
end
- def emit(tag, es, chain)
+ def process(tag, es)
begin
tag_output_es = @map_support.do_map(tag, es)
tag_output_es.each_pair do |tag, output_es|
router.emit_stream(tag, output_es)
end
- chain.next
tag_output_es
rescue SyntaxError => e
- chain.next
log.error "map command is syntax error: #{@map}"
e #for test
end
end
end