1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #308 from hindessm/avoid-debug-payload-corruption

Avoid corrupting message payload while logging.
This commit is contained in:
Nick O'Leary 2014-07-30 09:54:10 +01:00
commit a9ee417c1f

View File

@ -41,8 +41,7 @@ module.exports = function(RED) {
} else { // debug just the msg.payload } else { // debug just the msg.payload
if (this.console == "true") { if (this.console == "true") {
if (typeof msg.payload === "string") { if (typeof msg.payload === "string") {
if (msg.payload.indexOf("\n") != -1) { msg.payload = "\n"+msg.payload; } node.log((msg.payload.indexOf("\n") != -1 ? "\n" : "") + msg.payload);
node.log(msg.payload);
} }
else if (typeof msg.payload === "object") { node.log("\n"+util.inspect(msg.payload, {colors:useColors, depth:10})); } 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})); } else { node.log(util.inspect(msg.payload, {colors:useColors})); }