chaneg exec, file and inject node to use node.debug rather than -v flag

This commit is contained in:
Dave Conway-Jones 2021-12-17 09:58:10 +00:00
parent 7cd3e49f04
commit 2cad42870e
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
3 changed files with 8 additions and 14 deletions

View File

@ -75,16 +75,12 @@ module.exports = function(RED) {
node.repeaterSetup = function () { node.repeaterSetup = function () {
if (this.repeat && !isNaN(this.repeat) && this.repeat > 0) { if (this.repeat && !isNaN(this.repeat) && this.repeat > 0) {
this.repeat = this.repeat * 1000; this.repeat = this.repeat * 1000;
if (RED.settings.verbose) { this.debug(RED._("inject.repeat", this));
this.log(RED._("inject.repeat", this));
}
this.interval_id = setInterval(function() { this.interval_id = setInterval(function() {
node.emit("input", {}); node.emit("input", {});
}, this.repeat); }, this.repeat);
} else if (this.crontab) { } else if (this.crontab) {
if (RED.settings.verbose) { this.debug(RED._("inject.crontab", this));
this.log(RED._("inject.crontab", this));
}
this.cronjob = scheduleTask(this.crontab,() => { node.emit("input", {})}); this.cronjob = scheduleTask(this.crontab,() => { node.emit("input", {})});
} }
}; };
@ -148,10 +144,10 @@ module.exports = function(RED) {
} }
if (this.interval_id != null) { if (this.interval_id != null) {
clearInterval(this.interval_id); clearInterval(this.interval_id);
if (RED.settings.verbose) { this.log(RED._("inject.stopped")); } this.debug(RED._("inject.stopped"));
} else if (this.cronjob != null) { } else if (this.cronjob != null) {
this.cronjob.stop(); this.cronjob.stop();
if (RED.settings.verbose) { this.log(RED._("inject.stopped")); } this.debug(RED._("inject.stopped"));
delete this.cronjob; delete this.cronjob;
} }
}; };

View File

@ -86,7 +86,7 @@ module.exports = function(RED) {
}); });
var cmd = arg.shift(); var cmd = arg.shift();
/* istanbul ignore else */ /* istanbul ignore else */
if (RED.settings.verbose) { node.log(cmd+" ["+arg+"]"); } node.debug(cmd+" ["+arg+"]");
child = spawn(cmd,arg,node.spawnOpt); child = spawn(cmd,arg,node.spawnOpt);
node.status({fill:"blue",shape:"dot",text:"pid:"+child.pid}); node.status({fill:"blue",shape:"dot",text:"pid:"+child.pid});
var unknownCommand = (child.pid === undefined); var unknownCommand = (child.pid === undefined);
@ -136,7 +136,7 @@ module.exports = function(RED) {
} }
else { else {
/* istanbul ignore else */ /* istanbul ignore else */
if (RED.settings.verbose) { node.log(arg); } node.debug(arg);
child = exec(arg, node.execOpt, function (error, stdout, stderr) { child = exec(arg, node.execOpt, function (error, stdout, stderr) {
var msg2, msg3; var msg2, msg3;
delete msg.payload; delete msg.payload;
@ -155,7 +155,7 @@ module.exports = function(RED) {
if (error.signal) { msg3.payload.signal = error.signal; } if (error.signal) { msg3.payload.signal = error.signal; }
if (error.code === null) { node.status({fill:"red",shape:"dot",text:"killed"}); } if (error.code === null) { node.status({fill:"red",shape:"dot",text:"killed"}); }
else { node.status({fill:"red",shape:"dot",text:"error:"+error.code}); } else { node.status({fill:"red",shape:"dot",text:"error:"+error.code}); }
if (RED.settings.verbose) { node.log('error:' + error); } node.debug('error:' + error);
} }
else if (node.oldrc === "false") { else if (node.oldrc === "false") {
msg3 = RED.util.cloneMessage(msg); msg3 = RED.util.cloneMessage(msg);

View File

@ -71,9 +71,7 @@ module.exports = function(RED) {
node.error(RED._("file.errors.deletefail",{error:err.toString()}),msg); node.error(RED._("file.errors.deletefail",{error:err.toString()}),msg);
} }
else { else {
if (RED.settings.verbose) { node.debug(RED._("file.status.deletedfile",{file:filename}));
node.log(RED._("file.status.deletedfile",{file:filename}));
}
nodeSend(msg); nodeSend(msg);
} }
done(); done();