From 999b888c54665c2fadea2a8e5397b2cca95e8f0c Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Tue, 11 Aug 2015 19:39:37 +0100 Subject: [PATCH] debug nodes - show length of strings, buffers or size of arrays --- nodes/core/core/58-debug.html | 8 ++++---- nodes/core/core/58-debug.js | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/nodes/core/core/58-debug.html b/nodes/core/core/58-debug.html index 192b4634e..d4429b773 100644 --- a/nodes/core/core/58-debug.html +++ b/nodes/core/core/58-debug.html @@ -201,7 +201,7 @@ msg.className = 'debug-message'+(o.level?(' debug-message-level-'+o.level):''); msg.innerHTML = ''+ getTimestamp()+''+ - (name?'['+name+']':'')+ + (name?''+name:'')+ ''; // NOTE: relying on function error to have a "type" that all other msgs don't if (o.hasOwnProperty("type") && (o.type === "function")) { @@ -212,11 +212,11 @@ errorLvlType = 'warn'; } msg.className = 'debug-message debug-message-level-' + errorLvl; - msg.innerHTML += '[function] : (' + errorLvlType + ')'; + msg.innerHTML += 'function : (' + errorLvlType + ')'; } else { msg.innerHTML += ''+ (o.topic?topic+' : ':'')+ - (o.property?'[msg.'+property+']':'[msg]')+" : "+format+ + (o.property?'msg.'+property:'msg')+" : "+format+ ''; } @@ -284,7 +284,7 @@ .debug-message-topic { display: block; background: #fff; - padding: 1px 5px; + padding: 1px; font-size: 10px; color: #a66; } diff --git a/nodes/core/core/58-debug.js b/nodes/core/core/58-debug.js index 1dd707dae..2cbe3e18a 100644 --- a/nodes/core/core/58-debug.js +++ b/nodes/core/core/58-debug.js @@ -82,13 +82,13 @@ module.exports = function(RED) { msg.format = "error"; msg.msg = msg.msg.toString(); } else if (msg.msg instanceof Buffer) { - msg.format = "buffer"; + msg.format = "buffer ["+msg.msg.length+"]"; msg.msg = msg.msg.toString('hex'); } else if (typeof msg.msg === 'object') { var seen = []; msg.format = "object"; if (util.isArray(msg.msg)) { - msg.format = "array"; + msg.format = "array ["+msg.msg.length+"]"; } msg.msg = JSON.stringify(msg.msg, function(key, value) { if (typeof value === 'object' && value !== null) { @@ -111,7 +111,7 @@ module.exports = function(RED) { msg.format = (msg.msg === null)?"null":"undefined"; msg.msg = "(undefined)"; } else { - msg.format = "string"; + msg.format = "string ["+msg.msg.length+"]"; msg.msg = msg.msg; }