Fixing `--logLevel` option for `embark run`

Intercepting logs for embark run and including logLevel for displayed logs.
This commit is contained in:
emizzle 2018-04-17 16:17:59 +10:00
parent ad136802da
commit d985a5ed69
3 changed files with 8 additions and 3 deletions

View File

@ -102,6 +102,7 @@ class Cmd {
.option('--nodashboard', 'simple mode, disables the dashboard') .option('--nodashboard', 'simple mode, disables the dashboard')
.option('--no-color', 'no colors in case it\'s needed for compatbility purposes') .option('--no-color', 'no colors in case it\'s needed for compatbility purposes')
.option('--logfile [logfile]', 'filename to output logs (default: none)') .option('--logfile [logfile]', 'filename to output logs (default: none)')
.option('--logLevel [logLevel]', 'level of logging to display ["error", "warn", "info", "debug", "trace"] (default: debug)')
.description('run dapp (default: development)') .description('run dapp (default: development)')
.action(function (env, options) { .action(function (env, options) {
embark.run({ embark.run({
@ -110,7 +111,8 @@ class Cmd {
serverHost: options.host, serverHost: options.host,
runWebserver: !options.noserver, runWebserver: !options.noserver,
useDashboard: !options.nodashboard, useDashboard: !options.nodashboard,
logfile: options.logfile logfile: options.logfile,
logLevel: options.logLevel
}); });
}); });
} }

View File

@ -17,13 +17,14 @@ class Engine {
this.interceptLogs = options.interceptLogs; this.interceptLogs = options.interceptLogs;
this.version = options.version; this.version = options.version;
this.logfile = options.logfile; this.logfile = options.logfile;
this.logLevel = options.logLevel;
} }
init(_options) { init(_options) {
let self = this; let self = this;
let options = _options || {}; let options = _options || {};
this.events = new Events(); this.events = new Events();
this.logger = options.logger || new Logger({logLevel: options.logLevel || 'debug', events: this.events, logfile: this.logfile}); this.logger = options.logger || new Logger({logLevel: options.logLevel || this.logLevel || 'debug', events: this.events, logfile: this.logfile});
this.config = new Config({env: this.env, logger: this.logger, events: this.events}); this.config = new Config({env: this.env, logger: this.logger, events: this.events});
this.config.loadConfigFiles({embarkConfig: this.embarkConfig, interceptLogs: this.interceptLogs}); this.config.loadConfigFiles({embarkConfig: this.embarkConfig, interceptLogs: this.interceptLogs});
this.plugins = this.config.plugins; this.plugins = this.config.plugins;

View File

@ -61,7 +61,9 @@ class Embark {
env: options.env, env: options.env,
version: this.version, version: this.version,
embarkConfig: options.embarkConfig || 'embark.json', embarkConfig: options.embarkConfig || 'embark.json',
logfile: options.logfile logfile: options.logfile,
logLevel: options.logLevel,
interceptLogs: true
}); });
engine.init(); engine.init();