reorder component initialization make log clearer; improve log messages to make them clearer

This commit is contained in:
Iuri Matias 2017-02-15 20:56:18 -05:00
parent 617d40086c
commit fcd88b9e4a
6 changed files with 30 additions and 28 deletions

View File

@ -2,6 +2,7 @@ var Web3 = require('web3');
var Console = function(options) { var Console = function(options) {
this.plugins = options.plugins; this.plugins = options.plugins;
this.version = options.version;
}; };
Console.prototype.runCode = function(code) { Console.prototype.runCode = function(code) {
@ -19,7 +20,7 @@ Console.prototype.executeCmd = function(cmd, callback) {
if (cmd === 'help') { if (cmd === 'help') {
var helpText = [ var helpText = [
'Welcome to Embark 2', 'Welcome to Embark ' + this.version,
'', '',
'possible commands are:', 'possible commands are:',
// TODO: only if the blockchain is actually active! // TODO: only if the blockchain is actually active!

View File

@ -61,7 +61,7 @@ Deploy.prototype.checkAndDeployContract = function(contract, params, callback) {
var trackedContract = self.deployTracker.getContract(contract.className, contract.code, contract.args); var trackedContract = self.deployTracker.getContract(contract.className, contract.code, contract.args);
if (trackedContract && this.web3.eth.getCode(trackedContract.address) !== "0x") { if (trackedContract && this.web3.eth.getCode(trackedContract.address) !== "0x") {
self.logger.info(contract.className.cyan + " already deployed at ".green + trackedContract.address.cyan); self.logger.info(contract.className.bold.cyan + " already deployed at ".green + trackedContract.address.bold.cyan);
contract.deployedAddress = trackedContract.address; contract.deployedAddress = trackedContract.address;
self.logger.contractsState(self.contractsManager.contractsState()); self.logger.contractsState(self.contractsManager.contractsState());
return callback(); return callback();
@ -118,7 +118,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) {
gasPrice: contract.gasPrice gasPrice: contract.gasPrice
}); });
self.logger.info("deploying " + contract.className.cyan + " with ".green + contract.gas + " gas".green); self.logger.info("deploying " + contract.className.bold.cyan + " with ".green + contract.gas + " gas".green);
contractParams.push(function(err, transaction) { contractParams.push(function(err, transaction) {
self.logger.contractsState(self.contractsManager.contractsState()); self.logger.contractsState(self.contractsManager.contractsState());
@ -132,7 +132,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) {
contract.error = errMsg; contract.error = errMsg;
return callback(new Error(err)); return callback(new Error(err));
} else if (transaction.address !== undefined) { } else if (transaction.address !== undefined) {
self.logger.info(contract.className.cyan + " deployed at ".green + transaction.address.cyan); self.logger.info(contract.className.bold.cyan + " deployed at ".green + transaction.address.bold.cyan);
contract.deployedAddress = transaction.address; contract.deployedAddress = transaction.address;
contract.transactionHash = transaction.transactionHash; contract.transactionHash = transaction.transactionHash;
return callback(null, transaction.address); return callback(null, transaction.address);
@ -158,7 +158,7 @@ Deploy.prototype.deployAll = function(done) {
self.logger.error(err.message); self.logger.error(err.message);
self.logger.debug(err.stack); self.logger.debug(err.stack);
} }
self.logger.info("finished"); self.logger.info("finished deploying contracts");
self.logger.trace(arguments); self.logger.trace(arguments);
done(); done();
} }

View File

@ -79,7 +79,7 @@ var Embark = {
callback(); callback();
}, },
function startConsole(callback) { function startConsole(callback) {
Embark.console = new Console({plugins: self.plugins}); Embark.console = new Console({plugins: self.plugins, version: self.version});
callback(); callback();
}, },
function startMonitor(callback) { function startMonitor(callback) {
@ -101,6 +101,13 @@ var Embark = {
// TODO: do this after monitor is rendered // TODO: do this after monitor is rendered
callback(); callback();
}, },
function displayLoadedPlugins(callback) {
var pluginList = self.plugins.listPlugins();
if (pluginList.length > 0) {
self.logger.info("loaded plugins: " + pluginList.join(", "));
}
callback();
},
function monitorServices(callback) { function monitorServices(callback) {
if (!options.useDashboard) { if (!options.useDashboard) {
return callback(); return callback();
@ -117,18 +124,6 @@ var Embark = {
callback(); callback();
}, },
self.buildDeployGenerate.bind(self), self.buildDeployGenerate.bind(self),
function startAssetServer(callback) {
if (!options.runWebserver) {
return callback();
}
self.logger.setStatus("Starting Server");
var server = new Server({
logger: self.logger,
host: options.serverHost,
port: options.serverPort
});
server.start(callback);
},
function watchFilesForChanges(callback) { function watchFilesForChanges(callback) {
self.logger.setStatus("Watching for changes"); self.logger.setStatus("Watching for changes");
var watch = new Watch({logger: self.logger}); var watch = new Watch({logger: self.logger});
@ -144,19 +139,25 @@ var Embark = {
}); });
callback(); callback();
}, },
function displayLoadedPlugins(callback) { function startAssetServer(callback) {
var pluginList = self.plugins.listPlugins(); if (!options.runWebserver) {
if (pluginList.length > 0) { return callback();
self.logger.info("loaded plugins: " + pluginList.join(", "));
} }
callback(); self.logger.setStatus("Starting Server");
var server = new Server({
logger: self.logger,
host: options.serverHost,
port: options.serverPort
});
server.start(callback);
} }
], function(err, result) { ], function(err, result) {
if (err) { if (err) {
self.logger.error(err.message); self.logger.error(err.message);
} else { } else {
self.logger.setStatus("Ready".green); self.logger.setStatus("Ready".green);
self.logger.trace("finished".underline); self.logger.info("Looking for documentation? you can find it at ".cyan + "http://embark.readthedocs.io/".green.underline);
self.logger.info("Ready".underline);
} }
}); });
}, },

View File

@ -62,7 +62,7 @@ Pipeline.prototype.build = function(abi) {
contentFiles.map(function(file) { contentFiles.map(function(file) {
var filename = file.filename.replace('app/', ''); var filename = file.filename.replace('app/', '');
filename = filename.replace(targetDir, ''); filename = filename.replace(targetDir, '');
self.logger.info("writing file " + self.buildDir + targetDir + filename); self.logger.info("writing file " + (self.buildDir + targetDir + filename).bold.dim);
fs.writeFileSync(self.buildDir + targetDir + filename, fs.readFileSync(file.path)); fs.writeFileSync(self.buildDir + targetDir + filename, fs.readFileSync(file.path));
}); });
@ -71,7 +71,7 @@ Pipeline.prototype.build = function(abi) {
return file.content; return file.content;
}).join("\n"); }).join("\n");
self.logger.info("writing file " + this.buildDir + targetFile); self.logger.info("writing file " + (this.buildDir + targetFile).bold.dim);
fs.writeFileSync(this.buildDir + targetFile, content); fs.writeFileSync(this.buildDir + targetFile, content);
} }
} }

View File

@ -16,7 +16,7 @@ Server.prototype.start = function(callback) {
serve(req, res, finalhandler(req, res)); serve(req, res, finalhandler(req, res));
}); });
this.logger.info(("webserver available at http://" + this.hostname + ":" + this.port).underline.green); this.logger.info("webserver available at " + ("http://" + this.hostname + ":" + this.port).bold.underline.green);
server.listen(this.port, this.hostname) ; server.listen(this.port, this.hostname) ;
callback(); callback();
}; };

View File

@ -25,7 +25,7 @@ Watch.prototype.start = function() {
self.logger.trace('ready to watch config changes'); self.logger.trace('ready to watch config changes');
}); });
this.logger.info("ready to watch changes"); this.logger.info("ready to watch file changes");
}; };
Watch.prototype.watchAssets = function(embarkConfig, callback) { Watch.prototype.watchAssets = function(embarkConfig, callback) {