From fcd88b9e4a7f50ea8de3640558722f21f3551323 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 15 Feb 2017 20:56:18 -0500 Subject: [PATCH] reorder component initialization make log clearer; improve log messages to make them clearer --- lib/console.js | 3 ++- lib/deploy.js | 8 ++++---- lib/index.js | 39 ++++++++++++++++++++------------------- lib/pipeline.js | 4 ++-- lib/server.js | 2 +- lib/watch.js | 2 +- 6 files changed, 30 insertions(+), 28 deletions(-) diff --git a/lib/console.js b/lib/console.js index cee3ae1f5..c9cd02bd6 100644 --- a/lib/console.js +++ b/lib/console.js @@ -2,6 +2,7 @@ var Web3 = require('web3'); var Console = function(options) { this.plugins = options.plugins; + this.version = options.version; }; Console.prototype.runCode = function(code) { @@ -19,7 +20,7 @@ Console.prototype.executeCmd = function(cmd, callback) { if (cmd === 'help') { var helpText = [ - 'Welcome to Embark 2', + 'Welcome to Embark ' + this.version, '', 'possible commands are:', // TODO: only if the blockchain is actually active! diff --git a/lib/deploy.js b/lib/deploy.js index d2c50692e..a8b86b61e 100644 --- a/lib/deploy.js +++ b/lib/deploy.js @@ -61,7 +61,7 @@ Deploy.prototype.checkAndDeployContract = function(contract, params, callback) { var trackedContract = self.deployTracker.getContract(contract.className, contract.code, contract.args); 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; self.logger.contractsState(self.contractsManager.contractsState()); return callback(); @@ -118,7 +118,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) { 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) { self.logger.contractsState(self.contractsManager.contractsState()); @@ -132,7 +132,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) { contract.error = errMsg; return callback(new Error(err)); } 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.transactionHash = transaction.transactionHash; return callback(null, transaction.address); @@ -158,7 +158,7 @@ Deploy.prototype.deployAll = function(done) { self.logger.error(err.message); self.logger.debug(err.stack); } - self.logger.info("finished"); + self.logger.info("finished deploying contracts"); self.logger.trace(arguments); done(); } diff --git a/lib/index.js b/lib/index.js index ffc5af6af..8cc7063b2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -79,7 +79,7 @@ var Embark = { callback(); }, function startConsole(callback) { - Embark.console = new Console({plugins: self.plugins}); + Embark.console = new Console({plugins: self.plugins, version: self.version}); callback(); }, function startMonitor(callback) { @@ -101,6 +101,13 @@ var Embark = { // TODO: do this after monitor is rendered callback(); }, + function displayLoadedPlugins(callback) { + var pluginList = self.plugins.listPlugins(); + if (pluginList.length > 0) { + self.logger.info("loaded plugins: " + pluginList.join(", ")); + } + callback(); + }, function monitorServices(callback) { if (!options.useDashboard) { return callback(); @@ -117,18 +124,6 @@ var Embark = { callback(); }, 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) { self.logger.setStatus("Watching for changes"); var watch = new Watch({logger: self.logger}); @@ -144,19 +139,25 @@ var Embark = { }); callback(); }, - function displayLoadedPlugins(callback) { - var pluginList = self.plugins.listPlugins(); - if (pluginList.length > 0) { - self.logger.info("loaded plugins: " + pluginList.join(", ")); + function startAssetServer(callback) { + if (!options.runWebserver) { + return callback(); } - 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) { if (err) { self.logger.error(err.message); } else { 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); } }); }, diff --git a/lib/pipeline.js b/lib/pipeline.js index 5301f7135..042ada1a4 100644 --- a/lib/pipeline.js +++ b/lib/pipeline.js @@ -62,7 +62,7 @@ Pipeline.prototype.build = function(abi) { contentFiles.map(function(file) { var filename = file.filename.replace('app/', ''); 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)); }); @@ -71,7 +71,7 @@ Pipeline.prototype.build = function(abi) { return file.content; }).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); } } diff --git a/lib/server.js b/lib/server.js index fd32c4c5e..afbdad2a8 100644 --- a/lib/server.js +++ b/lib/server.js @@ -16,7 +16,7 @@ Server.prototype.start = function(callback) { 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) ; callback(); }; diff --git a/lib/watch.js b/lib/watch.js index 42092c8eb..9c94e1d84 100644 --- a/lib/watch.js +++ b/lib/watch.js @@ -25,7 +25,7 @@ Watch.prototype.start = function() { 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) {