From 445133cfdf98080e42dfa3ecaadd6560114ffbfe Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 27 Feb 2018 15:49:21 -0500 Subject: [PATCH] move setStatus from logger to event bus --- lib/core/engine.js | 4 ++-- lib/core/logger.js | 1 - lib/dashboard/dashboard.js | 2 +- lib/index.js | 2 +- lib/modules/webserver/index.js | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/core/engine.js b/lib/core/engine.js index fe9ec025..27b5cdd6 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -80,7 +80,7 @@ class Engine { pipelineService(_options) { let self = this; - this.logger.setStatus("Building Assets"); + this.events.emit("status", "Building Assets"); let pipeline = new Pipeline({ buildDir: this.config.buildDir, contractsFiles: this.config.contractsFiles, @@ -167,7 +167,7 @@ class Engine { } fileWatchService(_options) { - this.logger.setStatus("Watching for changes"); + this.events.emit("status", "Watching for changes"); let watch = new Watch({logger: this.logger, events: this.events}); watch.start(); } diff --git a/lib/core/logger.js b/lib/core/logger.js index 49de081e..d5a1c714 100644 --- a/lib/core/logger.js +++ b/lib/core/logger.js @@ -5,7 +5,6 @@ class Logger { this.logLevels = ['error', 'warn', 'info', 'debug', 'trace']; this.logLevel = options.logLevel || 'info'; this.logFunction = options.logFunction || console.log; - this.setStatus = options.setStatus || console.log; } } diff --git a/lib/dashboard/dashboard.js b/lib/dashboard/dashboard.js index 0c06d68f..b0d04c8b 100644 --- a/lib/dashboard/dashboard.js +++ b/lib/dashboard/dashboard.js @@ -30,9 +30,9 @@ class Dashboard { function startMonitor(callback) { monitor = new Monitor({env: self.env, console: console}); self.logger.logFunction = monitor.logEntry; - self.logger.setStatus = monitor.setStatus.bind(monitor); self.events.on('contractsState', monitor.setContracts); + self.events.on('status', monitor.setStatus.bind(monitor)); self.logger.info('========================'.bold.green); self.logger.info(('Welcome to Embark ' + self.version).yellow.bold); diff --git a/lib/index.js b/lib/index.js index f15e406f..2f6ace16 100644 --- a/lib/index.js +++ b/lib/index.js @@ -129,7 +129,7 @@ class Embark { engine.logger.info(err.stack); } else { engine.events.emit('firstDeploymentDone'); - engine.logger.setStatus("Ready".green); + engine.events.emit("status", "Ready".green); engine.logger.info("Looking for documentation? you can find it at ".cyan + "http://embark.readthedocs.io/".green.underline); engine.logger.info("Ready".underline); diff --git a/lib/modules/webserver/index.js b/lib/modules/webserver/index.js index 0e52723b..e3a313fe 100644 --- a/lib/modules/webserver/index.js +++ b/lib/modules/webserver/index.js @@ -16,7 +16,7 @@ class WebServer { this.host = options.host || this.webServerConfig.host; this.port = options.port || this.webServerConfig.port; - this.logger.setStatus("Starting Server"); + this.events.emit("status", "Starting Server"); this.server = new Server({logger: this.logger, host: this.host, port: this.port}); this.setServiceCheck();