lib/fluent/plugin/in_mqtt.rb in fluent-plugin-mqtt-0.0.6 vs lib/fluent/plugin/in_mqtt.rb in fluent-plugin-mqtt-0.0.7

- old
+ new

@@ -5,11 +5,17 @@ include Fluent::SetTagKeyMixin config_set_default :include_tag_key, false include Fluent::SetTimeKeyMixin config_set_default :include_time_key, true + + # Define `router` method of v0.12 to support v0.10 or earlier + unless method_defined?(:router) + define_method("router") { Fluent::Engine } + end + config_param :port, :integer, :default => 1883 config_param :bind, :string, :default => '127.0.0.1' config_param :topic, :string, :default => '#' config_param :format, :string, :default => 'none' config_param :username, :string, :default => nil @@ -65,17 +71,18 @@ emit topic, parsed_message[0], parsed_message[1] end end end + def emit topic, message, time = Fluent::Engine.now if message.class == Array message.each do |data| $log.debug "#{topic}: #{data}" - Fluent::Engine.emit(topic , time , data) + router.emit(topic , time , data) end else - Fluent::Engine.emit(topic , time , message) + router.emit(topic , time , message) end end def shutdown @thread.kill