From 500c3ec1466b3104263af8f46d04db33f8b05a63 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Fri, 13 Sep 2013 23:28:39 +0100 Subject: [PATCH] tweak debug - so booleans are obvious. --- nodes/core/58-debug.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/nodes/core/58-debug.js b/nodes/core/58-debug.js index 700c34c1c..5e83be3d9 100644 --- a/nodes/core/58-debug.js +++ b/nodes/core/58-debug.js @@ -28,12 +28,12 @@ function DebugNode(n) { this.on("input",function(msg) { if (this.active) { if (msg.payload instanceof Buffer) { - msg.payload = "(Buffer) "+msg.payload.toString(); + msg.payload = "(Buffer) "+msg.payload.toString(); } if (this.complete) { - DebugNode.send({id:this.id,name:this.name,topic:msg.topic,msg:msg,_path:msg._path}); + DebugNode.send({id:this.id,name:this.name,topic:msg.topic,msg:msg,_path:msg._path}); } else { - DebugNode.send({id:this.id,name:this.name,topic:msg.topic,msg:msg.payload,_path:msg._path}); + DebugNode.send({id:this.id,name:this.name,topic:msg.topic,msg:msg.payload,_path:msg._path}); } } }); @@ -44,7 +44,8 @@ RED.nodes.registerType("debug",DebugNode); DebugNode.send = function(msg) { if (msg.msg instanceof Error) { msg.msg = msg.msg.toString(); - } else if (typeof msg.msg === 'object') { + } + else if (typeof msg.msg === 'object') { try { msg.msg = "(Object) "+JSON.stringify(msg.msg,null,1); } @@ -53,7 +54,9 @@ DebugNode.send = function(msg) { console.log(err); msg.msg = "[Error] Can't stringify object with circular reference - see console log."; } - } else if (msg.msg == 0) msg.msg = "0"; + } + else if (typeof msg.msg === "boolean") msg.msg = "(boolean) "+msg.msg.toString(); + else if (msg.msg === 0) msg.msg = "0"; for (var i in DebugNode.activeConnections) { var ws = DebugNode.activeConnections[i]; @@ -92,11 +95,11 @@ RED.app.post("/debug/:id", function(req,res) { var node = RED.nodes.getNode(req.params.id); if (node != null) { if (node.active) { - node.active = false; - res.send(201); + node.active = false; + res.send(201); } else { - node.active = true; - res.send(200); + node.active = true; + res.send(200); } } else { res.send(404);