fix: add back log command for modules (#1969)

This commit is contained in:
Jonathan Rainville 2019-10-13 21:58:57 -04:00 committed by Iuri Matias
parent af3c0f0bcb
commit 918a00c24c
9 changed files with 69 additions and 17 deletions

View File

@ -139,7 +139,7 @@ class Console {
helpText.push(`${chalk.cyan(helpDescription.usage || matches.join("/"))} - ${helpDescription.description}`);
});
// Add end commands
helpText.push(chalk.cyan("quit") + " - " + __("to immediatly exit (alias: exit)"),
helpText.push(chalk.cyan("quit") + " - " + __("to immediately exit (alias: exit)"),
"",
__("The web3 object and the interfaces for the deployed contracts and their methods are also available"));
return helpText.join("\n");

View File

@ -35,6 +35,14 @@ export class ProcessLauncher {
this._subscribeToMessages();
}
setSilent(value) {
if (this.silent === value) {
return;
}
this.silent = value;
this.events.request('process:logs:register', {processName: this.name, eventName: `process:${this.name}:log`, silent: this.silent});
}
_isDebug() {
const argvString= process.execArgv.join();
return argvString.includes('--debug') || argvString.includes('--inspect');

View File

@ -7,6 +7,7 @@ import BlockchainAPI from "./api";
class Blockchain {
constructor(embark, options) {
this.embark = embark;
this.embarkConfig = embark.config.embarkConfig;
this.logger = embark.logger;
this.events = embark.events;
@ -16,6 +17,8 @@ class Blockchain {
this.startedClient = null;
this.plugins = options.plugins;
this.registerConsoleCommands();
embark.registerActionForEvent("pipeline:generateAll:before", this.addArtifactFile.bind(this));
this.blockchainNodes = {};
@ -137,6 +140,20 @@ class Blockchain {
});
}
registerConsoleCommands() {
this.embark.registerConsoleCommand({
matches: ['log blockchain on'],
process: (cmd, callback) => {
this.events.request('logs:ethereum:enable', callback);
}
});
this.embark.registerConsoleCommand({
matches: ['log blockchain off'],
process: (cmd, callback) => {
this.events.request('logs:ethereum:disable', callback);
}
});
}
}
module.exports = Blockchain;

View File

@ -60,12 +60,12 @@ export class BlockchainProcessLauncher {
this.blockchainProcess.kill();
});
this.events.on('logs:ethereum:enable', () => {
this.blockchainProcess.silent = false;
this.events.setCommandHandler('logs:ethereum:enable', () => {
this.blockchainProcess.setSilent(false);
});
this.events.on('logs:ethereum:disable', () => {
this.blockchainProcess.silent = true;
this.events.setCommandHandler('logs:ethereum:disable', () => {
this.blockchainProcess.setSilent(true);
});
this.events.on('exit', () => {

View File

@ -58,12 +58,13 @@ export class BlockchainProcessLauncher {
this.blockchainProcess.kill();
});
this.events.on('logs:ethereum:enable', () => {
this.blockchainProcess.silent = false;
this.events.setCommandHandler('logs:ethereum:enable', () => {
this.blockchainProcess.setSilent(false);
});
this.events.on('logs:ethereum:disable', () => {
this.blockchainProcess.silent = true;
this.events.setCommandHandler('logs:ethereum:disable', () => {
this.blockchainProcess.setSilent(true);
});
this.events.on('exit', () => {

View File

@ -67,6 +67,19 @@ class IPFS {
upload_ipfs.deploy(readyCb);
});
this.embark.registerConsoleCommand({
matches: ['log ipfs on'],
process: (cmd, callback) => {
this.events.request('logs:ipfs:enable', callback);
}
});
this.embark.registerConsoleCommand({
matches: ['log ipfs off'],
process: (cmd, callback) => {
this.events.request('logs:ipfs:disable', callback);
}
});
}
async setupIpfsApi() {

View File

@ -160,12 +160,12 @@ class StorageProcessesLauncher {
callback(error);
});
self.events.on('logs:swarm:enable', () => {
self.processes[storageName].silent = false;
self.events.setCommandHandler('logs:ipfs:enable', () => {
self.processes[storageName].setSilent(false);
});
self.events.on('logs:swarm:disable', () => {
self.processes[storageName].silent = true;
self.events.setCommandHandler('logs:ipfs:disable', () => {
self.processes[storageName].setSilent(true);
});
}

View File

@ -91,6 +91,19 @@ class Swarm {
upload_swarm.deploy(readyCb);
});
this.embark.registerConsoleCommand({
matches: ['log swarm on'],
process: (cmd, callback) => {
this.events.request('logs:swarm:enable', callback);
}
});
this.embark.registerConsoleCommand({
matches: ['log swarm off'],
process: (cmd, callback) => {
this.events.request('logs:swarm:disable', callback);
}
});
}
setupSwarmAPI() {

View File

@ -159,12 +159,12 @@ class StorageProcessesLauncher {
callback(error);
});
self.events.on('logs:swarm:enable', () => {
self.processes[storageName].silent = false;
self.events.setCommandHandler('logs:swarm:enable', () => {
self.processes[storageName].setSilent(false);
});
self.events.on('logs:swarm:disable', () => {
self.processes[storageName].silent = true;
self.events.setCommandHandler('logs:swarm:disable', () => {
self.processes[storageName].setSilent(true);
});
}