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

Tidy up debug message status count

This commit is contained in:
Nick O'Leary 2022-04-26 16:04:09 +01:00
parent a63dfc4650
commit 973b31521e
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
3 changed files with 53 additions and 52 deletions

View File

@ -456,7 +456,7 @@
var counter = { var counter = {
value: "counter", value: "counter",
label: "message count", label: RED._("node-red:debug.messageCount"),
hasValue: false hasValue: false
}; };

View File

@ -115,6 +115,9 @@ module.exports = function(RED) {
if (this.oldState) { if (this.oldState) {
this.status({}); this.status({});
} }
if (this.timeout) {
clearTimeout(this.timeout)
}
}) })
this.on("input", function(msg, send, done) { this.on("input", function(msg, send, done) {
if (hasOwnProperty.call(msg, "status") && hasOwnProperty.call(msg.status, "source") && hasOwnProperty.call(msg.status.source, "id") && (msg.status.source.id === node.id)) { if (hasOwnProperty.call(msg, "status") && hasOwnProperty.call(msg.status, "source") && hasOwnProperty.call(msg.status.source, "id") && (msg.status.source.id === node.id)) {
@ -122,9 +125,6 @@ module.exports = function(RED) {
return; return;
} }
if (node.tostatus === true) { if (node.tostatus === true) {
prepareStatus(msg, function(err,debugMsg) {
if (err) { node.error(err); return; }
if ( node.statusType === "counter" ){ if ( node.statusType === "counter" ){
const differenceOfTime = (new Date().getTime() - node.lastTime); const differenceOfTime = (new Date().getTime() - node.lastTime);
node.lastTime = new Date().getTime(); node.lastTime = new Date().getTime();
@ -140,8 +140,9 @@ module.exports = function(RED) {
node.status({fill:"blue", shape:"ring", text: node.counter}) node.status({fill:"blue", shape:"ring", text: node.counter})
}, 200) }, 200)
} }
} } else {
else { prepareStatus(msg, function(err,debugMsg) {
if (err) { node.error(err); return; }
var output = debugMsg.msg; var output = debugMsg.msg;
var st = (typeof output === 'string') ? output : util.inspect(output); var st = (typeof output === 'string') ? output : util.inspect(output);
var fill = "grey"; var fill = "grey";
@ -170,10 +171,9 @@ module.exports = function(RED) {
node.status(newStatus); node.status(newStatus);
node.oldState = JSON.stringify(newStatus); node.oldState = JSON.stringify(newStatus);
} }
}
}); });
} }
}
if (this.complete === "true") { if (this.complete === "true") {
// debug complete msg object // debug complete msg object

View File

@ -125,6 +125,7 @@
"msgprop": "message property", "msgprop": "message property",
"msgobj": "complete msg object", "msgobj": "complete msg object",
"autostatus": "same as debug output", "autostatus": "same as debug output",
"messageCount": "message count",
"to": "To", "to": "To",
"debtab": "debug tab", "debtab": "debug tab",
"tabcon": "debug tab and console", "tabcon": "debug tab and console",