fix: fix process logs not showing on errors (#1962)

This commit is contained in:
Jonathan Rainville 2019-10-13 21:31:20 -04:00 committed by Iuri Matias
parent 80df4fa11d
commit 913267b1ce
4 changed files with 17 additions and 11 deletions

View File

@ -45,6 +45,7 @@ class LogHandler {
*/
handleLog(msg, alreadyLogged = false) {
if (!msg) return;
msg.logLevel = msg.logLevel || msg.type;
// Sometimes messages come in with line breaks, so we need to break them up accordingly.
let processedMessages = [];
@ -86,11 +87,11 @@ class LogHandler {
}
this.logs.push(log);
this.events.emit(`process-log-${this.processName}`, log);
if ((this.silent && msg.type !== 'error') || alreadyLogged) {
if ((this.silent && msg.logLevel !== 'error') || alreadyLogged) {
return;
}
if (this.logger[msg.type]) {
return this.logger[msg.type](normalizeInput(message));
if (this.logger[msg.logLevel]) {
return this.logger[msg.logLevel](normalizeInput(message));
}
this.logger.debug(normalizeInput(message));
});

View File

@ -61,11 +61,16 @@ class EmbarkController {
engine.registerModuleGroup("blockchain");
engine.startEngine(async () => {
try {
const alreadyStarted = await engine.events.request2("blockchain:node:start", Object.assign(engine.config.blockchainConfig, {isStandalone: true}));
if (alreadyStarted) {
engine.logger.warn(__('Blockchain process already started. No need to run `embark blockchain`'));
process.exit(0);
}
} catch (e) {
engine.logger.error(e);
process.exit(1);
}
});
});
}

View File

@ -59,7 +59,7 @@ class Blockchain {
}
const clientFunctions = this.blockchainNodes[clientName];
if (!clientFunctions) {
return cb(__("Client %s not found", clientName));
return cb(__("Client %s not found in registered plugins", clientName));
}
let onStart = () => {
@ -91,7 +91,7 @@ class Blockchain {
const clientFunctions = this.blockchainNodes[clientName];
if (!clientFunctions) {
return cb(__("Client %s not found", clientName));
return cb(__("Client %s not found in registered plugins", clientName));
}
clientFunctions.stopFn.apply(clientFunctions, [

View File

@ -199,8 +199,8 @@ Blockchain.prototype.run = function () {
}
], function(err, cmd, args) {
if (err) {
self.logger.error(err.message);
return;
self.logger.error(err.message || err);
process.exit(1);
}
args = compact(args);