From 6c88ebd874fd4a024344638b27a63b5af6fe2f87 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 13 Mar 2018 06:57:02 -0400 Subject: [PATCH] move logger api call into logger --- lib/core/logger.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/core/logger.js b/lib/core/logger.js index 8aa02fe26..149d1eb9e 100644 --- a/lib/core/logger.js +++ b/lib/core/logger.js @@ -19,8 +19,23 @@ Logger.logLevels = { trace: 'trace' }; -Logger.prototype.writeToFile = function () { - if (!this.logFile) { +Logger.prototype.registerAPICall = function (plugins) { + const self = this; + + let plugin = plugins.createPlugin('dashboard', {}); + plugin.registerAPICall( + 'ws', + '/embark/logs', + (ws, req) => { + self.events.on("log", function(logLevel, logMsg) { + ws.send(JSON.stringify({msg: logMsg, msg_clear: logMsg.stripColors, logLevel: logLevel}), () => {}); + }); + } + ); +}; + +Logger.prototype.writeToFile = function (txt) { + if (!this.logfile) { return; }