From 96ea81894d56958cfa18353b132f6721d00e8aba Mon Sep 17 00:00:00 2001 From: Mark Hindess Date: Tue, 29 Jul 2014 10:51:04 +0100 Subject: [PATCH] Avoid corrupting message payload while logging. --- nodes/core/core/58-debug.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nodes/core/core/58-debug.js b/nodes/core/core/58-debug.js index 86f98dbe5..2c7b2b279 100644 --- a/nodes/core/core/58-debug.js +++ b/nodes/core/core/58-debug.js @@ -41,8 +41,7 @@ module.exports = function(RED) { } else { // debug just the msg.payload if (this.console == "true") { if (typeof msg.payload === "string") { - if (msg.payload.indexOf("\n") != -1) { msg.payload = "\n"+msg.payload; } - node.log(msg.payload); + node.log((msg.payload.indexOf("\n") != -1 ? "\n" : "") + msg.payload); } else if (typeof msg.payload === "object") { node.log("\n"+util.inspect(msg.payload, {colors:useColors, depth:10})); } else { node.log(util.inspect(msg.payload, {colors:useColors})); }