lib/fluent/plugin/in_mqtt.rb in fluent-plugin-mqtt-0.0.2 vs lib/fluent/plugin/in_mqtt.rb in fluent-plugin-mqtt-0.0.3
- old
+ new
@@ -20,11 +20,11 @@
@topic ||= conf['topic']
@port ||= conf['port']
end
def start
- $log.debug "start mqtt"
+ $log.debug "start mqtt #{@bind}"
@connect = MQTT::Client.connect({remote_host: @bind, remote_port: @port})
@connect.subscribe(@topic)
@thread = Thread.new do
@connect.get do |topic,message|
@@ -34,10 +34,17 @@
end
end
end
def emit topic, message , time = Fluent::Engine.now
- Fluent::Engine.emit(topic, time , message )
+ if message.class == Array
+ message.each do |data|
+ $log.debug "#{topic}: #{data}"
+ Fluent::Engine.emit(topic , time , data)
+ end
+ else
+ Fluent::Engine.emit(topic , time , message)
+ end
end
def json_parse message
begin
y = Yajl::Parser.new