Add back debug logging for device/connection start

This commit is contained in:
Andrew Stewart 2014-11-28 14:42:26 -08:00
parent 5811cf2518
commit 29583c0bd5
1 changed files with 30 additions and 12 deletions

View File

@ -333,14 +333,24 @@ Robot.prototype.startWork = function() {
// //
// Returns nothing // Returns nothing
Robot.prototype.startConnections = function(callback) { Robot.prototype.startConnections = function(callback) {
var starters = {};
Logger.info("Starting connections."); Logger.info("Starting connections.");
for (var n in this.connections) { var starters = Object.keys(this.connections).map(function(n) {
this[n] = this.connections[n]; var conn = this[n] = this.connections[n];
starters[n] = this.connections[n].connect;
} return function(cb) {
var str = "Starting connection '" + n + "'";
if (conn.host) {
str += " on host " + conn.host;
} else if (conn.port) {
str += " on port " + conn.port;
}
Logger.debug(str + ".");
return conn.connect.call(conn, cb);
};
}.bind(this));
return Async.parallel(starters, callback); return Async.parallel(starters, callback);
}; };
@ -351,14 +361,22 @@ Robot.prototype.startConnections = function(callback) {
// //
// Returns nothing // Returns nothing
Robot.prototype.startDevices = function(callback) { Robot.prototype.startDevices = function(callback) {
var starters = {};
Logger.info("Starting devices."); Logger.info("Starting devices.");
for (var n in this.devices) { var starters = Object.keys(this.devices).map(function(n) {
this[n] = this.devices[n]; var device = this[n] = this.devices[n];
starters[n] = this.devices[n].start.bind(this.devices[n]);
} return function(cb) {
var str = "Starting device '" + n + "'";
if (device.pin) {
str += " on pin " + device.pin;
}
Logger.debug(str + ".");
return device.start.call(device, cb);
};
}.bind(this));
return Async.parallel(starters, callback); return Async.parallel(starters, callback);
}; };