Use same formatting for all log strings

This commit is contained in:
Andrew Stewart 2014-06-10 11:33:52 -07:00
parent 17c1d4609f
commit 9406fddaad
8 changed files with 27 additions and 19 deletions

View File

@ -51,13 +51,14 @@ Adaptor.prototype.commands = function() {
//
// Returns nothing
Adaptor.prototype.connect = function(callback) {
Logger.info("Connecting to adaptor '" + this.name + "'...");
Logger.info("Connecting to adaptor '" + this.name + "'.");
callback(null);
return true;
};
// Public: Disconnects from the adaptor
//
// Returns nothing
Adaptor.prototype.disconnect = function() {
return Logger.info("Disconnecting from adaptor '" + this.name + "'...");
Logger.info("Disconnecting from adaptor '" + this.name + "'.");
};

View File

@ -70,11 +70,14 @@ Connection.prototype.toJSON = function() {
// Returns the result of the supplied callback function
Connection.prototype.connect = function(callback) {
var msg = "Connecting to " + this.name;
var msg = "Connecting to '" + this.name + "'";
if (this.port != null) {
msg += " on port " + this.port;
}
msg += ".";
Logger.info(msg);
return this.adaptor.connect(callback);
};
@ -83,12 +86,14 @@ Connection.prototype.connect = function(callback) {
//
// Returns nothing
Connection.prototype.disconnect = function() {
var msg = "Disconnecting from " + this.name;
var msg = "Disconnecting from '" + this.name + "'";
if (this.port != null) {
msg += " on port " + this.port;
}
msg += ".";
Logger.info(msg);
return this.adaptor.disconnect();
};
@ -100,7 +105,7 @@ Connection.prototype.disconnect = function() {
//
// Returns the set-up adaptor
Connection.prototype.initAdaptor = function(opts) {
Logger.debug("Loading adaptor '" + opts.adaptor + "'");
Logger.debug("Loading adaptor '" + opts.adaptor + "'.");
return this.robot.initAdaptor(opts.adaptor, this.self, opts);
};

View File

@ -54,12 +54,14 @@ Utils.subclass(Device, EventEmitter);
//
// Returns result of supplied callback
Device.prototype.start = function(callback) {
var msg = "Starting device " + this.name;
var msg = "Starting device '" + this.name + "'";
if (this.pin != null) {
msg += " on pin " + this.pin;
}
msg += ".";
Logger.info(msg);
return this.driver.start(callback);
};
@ -68,7 +70,7 @@ Device.prototype.start = function(callback) {
//
// Returns result of supplied callback
Device.prototype.halt = function() {
Logger.info("Halting device " + this.name);
Logger.info("Halting device '" + this.name + "'.");
return this.driver.halt();
};
@ -116,6 +118,6 @@ Device.prototype.defaultConnection = function() {
// Returns the set-up driver
Device.prototype.initDriver = function(opts) {
if (opts == null) { opts = {}; }
Logger.debug("Loading driver '" + opts.driver + "'");
Logger.debug("Loading driver '" + opts.driver + "'.");
return this.robot.initDriver(opts.driver, this.self, opts);
};

View File

@ -51,7 +51,7 @@ Driver.prototype.commands = function() {
//
// Returns nothing
Driver.prototype.start = function(callback) {
Logger.info("Driver " + this.name + " started");
Logger.info("Driver " + this.name + " started.");
callback(null);
return true;
};
@ -60,5 +60,5 @@ Driver.prototype.start = function(callback) {
//
// Returns nothing
Driver.prototype.halt = function() {
return Logger.info("Driver " + this.name + " halted");
Logger.info("Driver " + this.name + " halted.");
};

View File

@ -56,7 +56,7 @@ describe("Adaptor", function() {
});
it("logs that it's connecting to the adaptor", function() {
var string = "Connecting to adaptor 'adaptor'...";
var string = "Connecting to adaptor 'adaptor'.";
expect(Logger.info).to.be.calledWith(string);
});
@ -76,7 +76,7 @@ describe("Adaptor", function() {
});
it("logs that it's disconnecting to the adaptor", function() {
var string = "Disconnecting from adaptor 'adaptor'...";
var string = "Disconnecting from adaptor 'adaptor'.";
expect(Logger.info).to.be.calledWith(string);
});
});

View File

@ -4,7 +4,7 @@ var Robot = source("robot"),
Logger = source('logger'),
Utils = source('utils');
describe("Cylon.Connection", function() {
describe("Connection", function() {
var robot = new Robot({
name: "Robby",
connection: { name: 'loopback', adaptor: 'loopback', port: "/dev/null" }
@ -71,7 +71,7 @@ describe("Cylon.Connection", function() {
});
it("logs that it's connecting the device", function() {
var message = "Connecting to loopback on port /dev/null";
var message = "Connecting to 'loopback' on port /dev/null.";
expect(Logger.info).to.be.calledWith(message);
});
@ -94,7 +94,7 @@ describe("Cylon.Connection", function() {
});
it("logs that it's disconnecting from the device", function() {
var message = "Disconnecting from loopback on port /dev/null";
var message = "Disconnecting from 'loopback' on port /dev/null.";
expect(Logger.info).to.be.calledWith(message);
});

View File

@ -6,7 +6,7 @@ var Ping = source('test/ping'),
Logger = source('logger'),
Utils = source('utils');
describe("Cylon.Device", function() {
describe("Device", function() {
var robot = new Robot({
name: "TestingBot",
connection: { name: 'loopback', adaptor: 'loopback' }
@ -75,7 +75,7 @@ describe("Cylon.Device", function() {
it("logs that it's starting the device", function() {
stub(Logger, 'info');
var message = "Starting device ping on pin 13";
var message = "Starting device 'ping' on pin 13.";
device.start()
@ -100,7 +100,7 @@ describe("Cylon.Device", function() {
});
it("logs that it's halt the device", function() {
var message = "Halting device ping";
var message = "Halting device 'ping'.";
stub(Logger, 'info');
device.halt();

View File

@ -67,7 +67,7 @@ describe("Driver", function() {
});
it("logs that it's starting the driver", function() {
var string = "Driver driver started";
var string = "Driver driver started.";
expect(Logger.info).to.be.calledWith(string);
});
@ -87,7 +87,7 @@ describe("Driver", function() {
});
it("logs that it's halting the driver", function() {
expect(Logger.info).to.be.calledWith("Driver driver halted")
expect(Logger.info).to.be.calledWith("Driver driver halted.")
});
});
});