mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Tidy up all console.log util.log from core nodes.
Try to make log,warn,error more consistent behaviour. Especially make sure any existing catches produce errors
This commit is contained in:
parent
b6245bdef7
commit
71ff828947
@ -32,13 +32,13 @@ module.exports = function(RED) {
|
|||||||
|
|
||||||
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;
|
||||||
this.log("repeat = "+this.repeat);
|
if (RED.settings.verbose) { this.log("repeat = "+this.repeat); }
|
||||||
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 (cron) {
|
if (cron) {
|
||||||
this.log("crontab = "+this.crontab);
|
if (RED.settings.verbose) { this.log("crontab = "+this.crontab); }
|
||||||
this.cronjob = new cron.CronJob(this.crontab,
|
this.cronjob = new cron.CronJob(this.crontab,
|
||||||
function() {
|
function() {
|
||||||
node.emit("input",{});
|
node.emit("input",{});
|
||||||
@ -72,10 +72,10 @@ module.exports = function(RED) {
|
|||||||
InjectNode.prototype.close = function() {
|
InjectNode.prototype.close = function() {
|
||||||
if (this.interval_id != null) {
|
if (this.interval_id != null) {
|
||||||
clearInterval(this.interval_id);
|
clearInterval(this.interval_id);
|
||||||
this.log("inject: repeat stopped");
|
if (RED.settings.verbose) { this.log("inject: repeat stopped"); }
|
||||||
} else if (this.cronjob != null) {
|
} else if (this.cronjob != null) {
|
||||||
this.cronjob.stop();
|
this.cronjob.stop();
|
||||||
this.log("inject: cronjob stopped");
|
if (RED.settings.verbose) { this.log("inject: cronjob stopped"); }
|
||||||
delete this.cronjob;
|
delete this.cronjob;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,7 +89,6 @@ module.exports = function(RED) {
|
|||||||
} catch(err) {
|
} catch(err) {
|
||||||
res.send(500);
|
res.send(500);
|
||||||
node.error("Inject failed:"+err);
|
node.error("Inject failed:"+err);
|
||||||
console.log(err.stack);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res.send(404);
|
res.send(404);
|
||||||
|
@ -58,7 +58,7 @@ module.exports = function(RED) {
|
|||||||
node.send([null,null,msg]);
|
node.send([null,null,msg]);
|
||||||
});
|
});
|
||||||
ex.on('error', function (code) {
|
ex.on('error', function (code) {
|
||||||
node.warn(code);
|
node.error(code);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else { node.error("Spawn command must be just the command - no spaces or extra parameters"); }
|
else { node.error("Spawn command must be just the command - no spaces or extra parameters"); }
|
||||||
|
@ -147,7 +147,6 @@ module.exports = function(RED) {
|
|||||||
node.send(node.buffer.shift()); // send the first on the queue
|
node.send(node.buffer.shift()); // send the first on the queue
|
||||||
}
|
}
|
||||||
node.status({text:node.buffer.length});
|
node.status({text:node.buffer.length});
|
||||||
//console.log(node.buffer);
|
|
||||||
},node.rate);
|
},node.rate);
|
||||||
|
|
||||||
this.on("input", function(msg) {
|
this.on("input", function(msg) {
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
module.exports = function(RED) {
|
module.exports = function(RED) {
|
||||||
"use strict";
|
"use strict";
|
||||||
var util = require("util");
|
|
||||||
var ArduinoFirmata = require('arduino-firmata');
|
var ArduinoFirmata = require('arduino-firmata');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var plat = require('os').platform();
|
var plat = require('os').platform();
|
||||||
@ -33,14 +32,14 @@ module.exports = function(RED) {
|
|||||||
var node = this;
|
var node = this;
|
||||||
node.board = new ArduinoFirmata();
|
node.board = new ArduinoFirmata();
|
||||||
if (portlist.indexOf(node.device) === -1) {
|
if (portlist.indexOf(node.device) === -1) {
|
||||||
node.warn("Device "+node.device+" not found");
|
node.warn("device "+node.device+" not found");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
node.board.connect(node.device);
|
node.board.connect(node.device);
|
||||||
}
|
}
|
||||||
|
|
||||||
node.board.on('boardReady', function(){
|
node.board.on('boardReady', function(){
|
||||||
node.log("version "+node.board.boardVersion);
|
if (RED.settings.verbose) { node.log("version "+node.board.boardVersion); }
|
||||||
});
|
});
|
||||||
|
|
||||||
node.on('close', function(done) {
|
node.on('close', function(done) {
|
||||||
@ -48,7 +47,7 @@ module.exports = function(RED) {
|
|||||||
try {
|
try {
|
||||||
node.board.close(function() {
|
node.board.close(function() {
|
||||||
done();
|
done();
|
||||||
node.log("port closed");
|
if (RED.settings.verbose) { node.log("port closed"); }
|
||||||
});
|
});
|
||||||
} catch(e) { done(); }
|
} catch(e) { done(); }
|
||||||
} else { done(); }
|
} else { done(); }
|
||||||
@ -95,7 +94,7 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
util.log("[Firmata-arduino] port not configured");
|
this.warn("port not configured");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("arduino in",DuinoNodeIn);
|
RED.nodes.registerType("arduino in",DuinoNodeIn);
|
||||||
@ -145,7 +144,7 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
util.log("[Firmata-arduino] port not configured");
|
this.warn("port not configured");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("arduino out",DuinoNodeOut);
|
RED.nodes.registerType("arduino out",DuinoNodeOut);
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
module.exports = function(RED) {
|
module.exports = function(RED) {
|
||||||
"use strict";
|
"use strict";
|
||||||
var util = require("util");
|
|
||||||
var exec = require('child_process').exec;
|
var exec = require('child_process').exec;
|
||||||
var spawn = require('child_process').spawn;
|
var spawn = require('child_process').spawn;
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
@ -24,17 +23,17 @@ module.exports = function(RED) {
|
|||||||
var gpioCommand = __dirname+'/nrgpio';
|
var gpioCommand = __dirname+'/nrgpio';
|
||||||
|
|
||||||
if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi
|
if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi
|
||||||
//util.log("Info : Ignoring Raspberry Pi specific node.");
|
//RED.log.info("Ignoring Raspberry Pi specific node.");
|
||||||
throw "Info : Ignoring Raspberry Pi specific node.";
|
throw "Info : Ignoring Raspberry Pi specific node.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fs.existsSync("/usr/share/doc/python-rpi.gpio")) {
|
if (!fs.existsSync("/usr/share/doc/python-rpi.gpio")) {
|
||||||
util.log("[rpi-gpio] Info : Can't find Pi RPi.GPIO python library.");
|
RED.log.warn("Can't find Pi RPi.GPIO python library.");
|
||||||
throw "Warning : Can't find Pi RPi.GPIO python library.";
|
throw "Warning : Can't find Pi RPi.GPIO python library.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !(1 & parseInt ((fs.statSync(gpioCommand).mode & parseInt ("777", 8)).toString (8)[0]) )) {
|
if ( !(1 & parseInt ((fs.statSync(gpioCommand).mode & parseInt ("777", 8)).toString (8)[0]) )) {
|
||||||
util.log("[rpi-gpio] Error : "+gpioCommand+" needs to be executable.");
|
RED.log.error(gpioCommand+" needs to be executable.");
|
||||||
throw "Error : nrgpio must to be executable.";
|
throw "Error : nrgpio must to be executable.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +99,7 @@ module.exports = function(RED) {
|
|||||||
node.child.on('error', function (err) {
|
node.child.on('error', function (err) {
|
||||||
if (err.errno === "ENOENT") { node.error('nrgpio command not found'); }
|
if (err.errno === "ENOENT") { node.error('nrgpio command not found'); }
|
||||||
else if (err.errno === "EACCES") { node.error('nrgpio command not executable'); }
|
else if (err.errno === "EACCES") { node.error('nrgpio command not executable'); }
|
||||||
else { node.log('error: ' + err); }
|
else { node.error('error: ' + err.errno); }
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -191,7 +190,7 @@ module.exports = function(RED) {
|
|||||||
node.child.on('error', function (err) {
|
node.child.on('error', function (err) {
|
||||||
if (err.errno === "ENOENT") { node.error('nrgpio command not found'); }
|
if (err.errno === "ENOENT") { node.error('nrgpio command not found'); }
|
||||||
else if (err.errno === "EACCES") { node.error('nrgpio command not executable'); }
|
else if (err.errno === "EACCES") { node.error('nrgpio command not executable'); }
|
||||||
else { node.log('error: ' + err); }
|
else { node.error('error: ' + err.errno); }
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -215,14 +214,14 @@ module.exports = function(RED) {
|
|||||||
var pitype = { type:"" };
|
var pitype = { type:"" };
|
||||||
exec(gpioCommand+" rev 0", function(err,stdout,stderr) {
|
exec(gpioCommand+" rev 0", function(err,stdout,stderr) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('[rpi-gpio] Version command failed for some reason.');
|
RED.log.info('Version command failed for some reason.');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (stdout.trim() == "0") { pitype = { type:"Compute" }; }
|
if (stdout.trim() == "0") { pitype = { type:"Compute" }; }
|
||||||
else if (stdout.trim() == "1") { pitype = { type:"A/B v1" }; }
|
else if (stdout.trim() == "1") { pitype = { type:"A/B v1" }; }
|
||||||
else if (stdout.trim() == "2") { pitype = { type:"A/B v2" }; }
|
else if (stdout.trim() == "2") { pitype = { type:"A/B v2" }; }
|
||||||
else if (stdout.trim() == "3") { pitype = { type:"Model B+" }; }
|
else if (stdout.trim() == "3") { pitype = { type:"Model B+" }; }
|
||||||
else { console.log("SAW Pi TYPE",stdout.trim()); }
|
else { RED.log.info("Saw Pi Type",stdout.trim()); }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RED.nodes.registerType("rpi-gpio out",GPIOOutNode);
|
RED.nodes.registerType("rpi-gpio out",GPIOOutNode);
|
||||||
@ -259,7 +258,7 @@ module.exports = function(RED) {
|
|||||||
node.child.on('error', function (err) {
|
node.child.on('error', function (err) {
|
||||||
if (err.errno === "ENOENT") { node.error('nrgpio command not found'); }
|
if (err.errno === "ENOENT") { node.error('nrgpio command not found'); }
|
||||||
else if (err.errno === "EACCES") { node.error('nrgpio ommand not executable'); }
|
else if (err.errno === "EACCES") { node.error('nrgpio ommand not executable'); }
|
||||||
else { node.log('error: ' + err); }
|
else { node.error('error: ' + err.errno); }
|
||||||
});
|
});
|
||||||
|
|
||||||
node.on("close", function(done) {
|
node.on("close", function(done) {
|
||||||
|
@ -38,11 +38,10 @@ if len(sys.argv) > 1:
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
data = raw_input()
|
data = raw_input()
|
||||||
if data == "close":
|
if 'close' in data:
|
||||||
GPIO.cleanup(pin)
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
p.ChangeDutyCycle(float(data))
|
p.ChangeDutyCycle(float(data))
|
||||||
except EOFError: # hopefully always caused by us sigint'ing the program
|
except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program
|
||||||
GPIO.cleanup(pin)
|
GPIO.cleanup(pin)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
@ -57,15 +56,14 @@ if len(sys.argv) > 1:
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
data = raw_input()
|
data = raw_input()
|
||||||
if data == "close":
|
if 'close' in data:
|
||||||
GPIO.cleanup(pin)
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif float(data) == 0:
|
elif float(data) == 0:
|
||||||
p.stop()
|
p.stop()
|
||||||
else:
|
else:
|
||||||
p.start(50)
|
p.start(50)
|
||||||
p.ChangeFrequency(float(data))
|
p.ChangeFrequency(float(data))
|
||||||
except EOFError: # hopefully always caused by us sigint'ing the program
|
except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program
|
||||||
GPIO.cleanup(pin)
|
GPIO.cleanup(pin)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
@ -80,11 +78,10 @@ if len(sys.argv) > 1:
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
data = raw_input()
|
data = raw_input()
|
||||||
if data == "close":
|
if 'close' in data:
|
||||||
GPIO.cleanup(pin)
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
data = int(data)
|
data = int(data)
|
||||||
except EOFError: # hopefully always caused by us sigint'ing the program
|
except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program
|
||||||
GPIO.cleanup(pin)
|
GPIO.cleanup(pin)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
except:
|
except:
|
||||||
@ -113,10 +110,9 @@ if len(sys.argv) > 1:
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
data = raw_input()
|
data = raw_input()
|
||||||
if data == "close":
|
if 'close' in data:
|
||||||
GPIO.cleanup(pin)
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
except EOFError: # hopefully always caused by us sigint'ing the program
|
except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program
|
||||||
GPIO.cleanup(pin)
|
GPIO.cleanup(pin)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
@ -128,11 +124,10 @@ if len(sys.argv) > 1:
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
data = raw_input()
|
data = raw_input()
|
||||||
if data == "close":
|
if 'close' in data:
|
||||||
GPIO.cleanup()
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
data = int(data)
|
data = int(data)
|
||||||
except EOFError: # hopefully always caused by us sigint'ing the program
|
except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program
|
||||||
GPIO.cleanup()
|
GPIO.cleanup()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
except:
|
except:
|
||||||
@ -159,14 +154,13 @@ if len(sys.argv) > 1:
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
data = raw_input()
|
data = raw_input()
|
||||||
if data == "close":
|
if 'close' in data:
|
||||||
GPIO.cleanup()
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
c = data.split(",")
|
c = data.split(",")
|
||||||
r.ChangeDutyCycle(float(c[0]))
|
r.ChangeDutyCycle(float(c[0]))
|
||||||
g.ChangeDutyCycle(float(c[1]))
|
g.ChangeDutyCycle(float(c[1]))
|
||||||
b.ChangeDutyCycle(float(c[2]))
|
b.ChangeDutyCycle(float(c[2]))
|
||||||
except EOFError: # hopefully always caused by us sigint'ing the program
|
except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program
|
||||||
GPIO.cleanup()
|
GPIO.cleanup()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
except:
|
except:
|
||||||
|
@ -174,7 +174,7 @@ module.exports = function(RED) {
|
|||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { console.log("Should never get here"); }
|
else { node.log("should never get here"); }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.port.on('ready', function() {
|
this.port.on('ready', function() {
|
||||||
@ -235,7 +235,7 @@ module.exports = function(RED) {
|
|||||||
// },true, function(err, results) { if (err) obj.serial.emit('error',err); });
|
// },true, function(err, results) { if (err) obj.serial.emit('error',err); });
|
||||||
//}
|
//}
|
||||||
obj.serial.on('error', function(err) {
|
obj.serial.on('error', function(err) {
|
||||||
util.log("[serial] serial port "+port+" error "+err);
|
RED.log.error("serial port "+port+" error "+err);
|
||||||
obj._emitter.emit('closed');
|
obj._emitter.emit('closed');
|
||||||
obj.tout = setTimeout(function() {
|
obj.tout = setTimeout(function() {
|
||||||
setupSerial();
|
setupSerial();
|
||||||
@ -243,7 +243,7 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
obj.serial.on('close', function() {
|
obj.serial.on('close', function() {
|
||||||
if (!obj._closing) {
|
if (!obj._closing) {
|
||||||
util.log("[serial] serial port "+port+" closed unexpectedly");
|
RED.log.error("serial port "+port+" closed unexpectedly");
|
||||||
obj._emitter.emit('closed');
|
obj._emitter.emit('closed');
|
||||||
obj.tout = setTimeout(function() {
|
obj.tout = setTimeout(function() {
|
||||||
setupSerial();
|
setupSerial();
|
||||||
@ -251,7 +251,7 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
obj.serial.on('open',function() {
|
obj.serial.on('open',function() {
|
||||||
util.log("[serial] serial port "+port+" opened at "+baud+" baud "+databits+""+parity.charAt(0).toUpperCase()+stopbits);
|
RED.log.info("serial port "+port+" opened at "+baud+" baud "+databits+""+parity.charAt(0).toUpperCase()+stopbits);
|
||||||
if (obj.tout) { clearTimeout(obj.tout); }
|
if (obj.tout) { clearTimeout(obj.tout); }
|
||||||
//obj.serial.flush();
|
//obj.serial.flush();
|
||||||
obj._emitter.emit('ready');
|
obj._emitter.emit('ready');
|
||||||
@ -269,7 +269,7 @@ module.exports = function(RED) {
|
|||||||
//}
|
//}
|
||||||
});
|
});
|
||||||
obj.serial.on("disconnect",function() {
|
obj.serial.on("disconnect",function() {
|
||||||
util.log("[serial] serial port "+port+" gone away");
|
RED.log.error("serial port "+port+" gone away");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setupSerial();
|
setupSerial();
|
||||||
@ -286,7 +286,7 @@ module.exports = function(RED) {
|
|||||||
connections[port]._closing = true;
|
connections[port]._closing = true;
|
||||||
try {
|
try {
|
||||||
connections[port].close(function() {
|
connections[port].close(function() {
|
||||||
util.log("[serial] serial port closed");
|
RED.log.info("serial port closed");
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,9 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
server.bind(node.port,node.iface);
|
// Hack for when you have both in and out udp nodes sharing a port
|
||||||
|
// if udp in starts last it shares better - so give it a chance to be last
|
||||||
|
setTimeout( function() { server.bind(node.port,node.iface); }, 250);;
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("udp in",UDPin);
|
RED.nodes.registerType("udp in",UDPin);
|
||||||
|
|
||||||
|
@ -61,7 +61,6 @@
|
|||||||
access_token: {type: "password"},
|
access_token: {type: "password"},
|
||||||
access_token_secret: {type:"password"}
|
access_token_secret: {type:"password"}
|
||||||
},
|
},
|
||||||
|
|
||||||
label: function() {
|
label: function() {
|
||||||
return this.screen_name;
|
return this.screen_name;
|
||||||
},
|
},
|
||||||
@ -181,7 +180,6 @@
|
|||||||
|
|
||||||
});
|
});
|
||||||
$("#node-input-user").change();
|
$("#node-input-user").change();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -218,7 +218,7 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
stream.on('limit', function(tweet) {
|
stream.on('limit', function(tweet) {
|
||||||
node.log("tweet rate limit hit");
|
node.warn("tweet rate limit hit");
|
||||||
});
|
});
|
||||||
stream.on('error', function(tweet,rc) {
|
stream.on('error', function(tweet,rc) {
|
||||||
if (rc == 420) {
|
if (rc == 420) {
|
||||||
@ -367,8 +367,8 @@ module.exports = function(RED) {
|
|||||||
credentials.oauth_verifier,
|
credentials.oauth_verifier,
|
||||||
function(error, oauth_access_token, oauth_access_token_secret, results){
|
function(error, oauth_access_token, oauth_access_token_secret, results){
|
||||||
if (error){
|
if (error){
|
||||||
console.log(error);
|
RED.log.error(error);
|
||||||
res.send("yeah something broke.");
|
res.send("something in twitter oauth broke.");
|
||||||
} else {
|
} else {
|
||||||
credentials = {};
|
credentials = {};
|
||||||
credentials.access_token = oauth_access_token;
|
credentials.access_token = oauth_access_token;
|
||||||
|
@ -57,7 +57,7 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
tail.stderr.on("data", function(data) {
|
tail.stderr.on("data", function(data) {
|
||||||
node.warn(data.toString());
|
node.error(data.toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
this.on("close", function() {
|
this.on("close", function() {
|
||||||
|
@ -40,7 +40,7 @@ module.exports = function(RED) {
|
|||||||
} else if (msg.hasOwnProperty('delete')) {
|
} else if (msg.hasOwnProperty('delete')) {
|
||||||
node.warn("Deprecated: please use specific delete option in config dialog.");
|
node.warn("Deprecated: please use specific delete option in config dialog.");
|
||||||
fs.unlink(filename, function (err) {
|
fs.unlink(filename, function (err) {
|
||||||
if (err) { node.warn('Failed to delete file : '+err); }
|
if (err) { node.error('Failed to delete file : '+err); }
|
||||||
});
|
});
|
||||||
} else if (typeof msg.payload != "undefined") {
|
} else if (typeof msg.payload != "undefined") {
|
||||||
var data = msg.payload;
|
var data = msg.payload;
|
||||||
@ -53,13 +53,13 @@ module.exports = function(RED) {
|
|||||||
// using "binary" not {encoding:"binary"} to be 0.8 compatible for a while
|
// using "binary" not {encoding:"binary"} to be 0.8 compatible for a while
|
||||||
//fs.writeFile(filename, data, {encoding:"binary"}, function (err) {
|
//fs.writeFile(filename, data, {encoding:"binary"}, function (err) {
|
||||||
fs.writeFile(filename, data, "binary", function (err) {
|
fs.writeFile(filename, data, "binary", function (err) {
|
||||||
if (err) { node.warn('Failed to write to file : '+err); }
|
if (err) { node.error('Failed to write to file : '+err); }
|
||||||
else if (RED.settings.verbose) { node.log('wrote to file: '+filename); }
|
else if (RED.settings.verbose) { node.log('wrote to file: '+filename); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (this.overwriteFile === "delete") {
|
else if (this.overwriteFile === "delete") {
|
||||||
fs.unlink(filename, function (err) {
|
fs.unlink(filename, function (err) {
|
||||||
if (err) { node.warn('Failed to delete file : '+err); }
|
if (err) { node.error('Failed to delete file : '+err); }
|
||||||
else if (RED.settings.verbose) { node.log("deleted file: "+filename); }
|
else if (RED.settings.verbose) { node.log("deleted file: "+filename); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ module.exports = function(RED) {
|
|||||||
// using "binary" not {encoding:"binary"} to be 0.8 compatible for a while longer
|
// using "binary" not {encoding:"binary"} to be 0.8 compatible for a while longer
|
||||||
//fs.appendFile(filename, data, {encoding:"binary"}, function (err) {
|
//fs.appendFile(filename, data, {encoding:"binary"}, function (err) {
|
||||||
fs.appendFile(filename, data, "binary", function (err) {
|
fs.appendFile(filename, data, "binary", function (err) {
|
||||||
if (err) { node.warn('Failed to append to file : '+err); }
|
if (err) { node.error('Failed to append to file : '+err); }
|
||||||
else if (RED.settings.verbose) { node.log('appended to file: '+filename); }
|
else if (RED.settings.verbose) { node.log('appended to file: '+filename); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ module.exports = function(RED) {
|
|||||||
msg.filename = filename;
|
msg.filename = filename;
|
||||||
fs.readFile(filename,options,function(err,data) {
|
fs.readFile(filename,options,function(err,data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
node.warn(err);
|
node.error(err);
|
||||||
msg.error = err;
|
msg.error = err;
|
||||||
delete msg.payload;
|
delete msg.payload;
|
||||||
} else {
|
} else {
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
module.exports = function(RED) {
|
module.exports = function(RED) {
|
||||||
"use strict";
|
"use strict";
|
||||||
var util = require("util");
|
|
||||||
var redis = require("redis");
|
var redis = require("redis");
|
||||||
|
|
||||||
var hashFieldRE = /^([^=]+)=(.*)$/;
|
var hashFieldRE = /^([^=]+)=(.*)$/;
|
||||||
@ -29,10 +28,10 @@ module.exports = function(RED) {
|
|||||||
if (!connections[id]) {
|
if (!connections[id]) {
|
||||||
connections[id] = redis.createClient(port,host);
|
connections[id] = redis.createClient(port,host);
|
||||||
connections[id].on("error",function(err) {
|
connections[id].on("error",function(err) {
|
||||||
util.log("[redis] "+err);
|
RED.log.error(err);
|
||||||
});
|
});
|
||||||
connections[id].on("connect",function() {
|
connections[id].on("connect",function() {
|
||||||
util.log("[redis] connected to "+host+":"+port);
|
if (RED.settings.verbose) { RED.log.info("connected to "+host+":"+port); }
|
||||||
});
|
});
|
||||||
connections[id]._id = id;
|
connections[id]._id = id;
|
||||||
connections[id]._nodeCount = 0;
|
connections[id]._nodeCount = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user