hide logs for on Deploy if silent

This commit is contained in:
Jonathan Rainville 2018-08-07 16:04:26 -04:00 committed by Iuri Matias
parent 2edd45ef55
commit ea0d846012
1 changed files with 7 additions and 5 deletions

View File

@ -63,10 +63,11 @@ class SpecialConfigs {
});
}
runOnDeployCode(onDeployCode, callback) {
runOnDeployCode(onDeployCode, callback, silent) {
const self = this;
const logFunction = silent ? self.logger.trace.bind(self.logger) : self.logger.info.bind(self.logger);
async.each(onDeployCode, (cmd, eachCb) => {
self.logger.info("==== executing: " + cmd);
logFunction("==== executing: " + cmd);
self.events.request('runcode:eval', cmd, (err) => {
if (err && err.message.indexOf("invalid opcode") >= 0) {
self.logger.error('the transaction was rejected; this usually happens due to a throw or a require, it can also happen due to an invalid operation');
@ -85,8 +86,9 @@ class SpecialConfigs {
if (!contract.onDeploy) {
return cb();
}
if (!contract.silent) {
self.logger.info(__('executing onDeploy commands'));
}
let onDeployCmds = contract.onDeploy;
@ -97,7 +99,7 @@ class SpecialConfigs {
return cb(new Error("error running onDeploy for " + contract.className.cyan));
}
self.runOnDeployCode(onDeployCode, cb);
self.runOnDeployCode(onDeployCode, cb, contract.silent);
});
});
}