move logger api call into logger

This commit is contained in:
Iuri Matias 2018-03-13 06:57:02 -04:00
parent e36dd40ca1
commit 7868a72f3b
2 changed files with 17 additions and 8 deletions

View File

@ -11,8 +11,23 @@ class Logger {
}
}
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;
}

View File

@ -36,12 +36,6 @@ class Server {
expressWebSocket(app);
app.ws('/embark/logs', function(ws, req) {
self.events.on("log", function(logLevel, logMsg) {
ws.send(JSON.stringify({msg: logMsg, msg_clear: logMsg.stripColors, logLevel: logLevel}), () => {});
});
});
let apiCalls = self.plugins.getPluginsProperty("apiCalls", "apiCalls");
for (let apiCall of apiCalls) {
app[apiCall.method].apply(app, [apiCall.endpoint, apiCall.cb]);