move logger api call into logger
This commit is contained in:
parent
3d5ceb74be
commit
cfc7266415
|
@ -34,6 +34,7 @@ class Engine {
|
|||
if (this.interceptLogs || this.interceptLogs === undefined) {
|
||||
this.doInterceptLogs();
|
||||
}
|
||||
this.logger.registerAPICall(this.plugins);
|
||||
}
|
||||
|
||||
doInterceptLogs() {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,12 +38,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]);
|
||||
|
|
Loading…
Reference in New Issue