Commit 70c952fc authored by Cédric Moreau's avatar Cédric Moreau
Browse files

Added logging date to websocket logs

parent 3c12fc1b
......@@ -8,12 +8,13 @@ var CallbackLogger = winston.transports.CallbackLogger = function (options) {
this.name = 'customLogger';
this.level = options.level || 'info';
this.callback = options.callback;
this.timestamp = options.timestamp;
};
util.inherits(CallbackLogger, winston.Transport);
CallbackLogger.prototype.log = function (level, msg, meta, callback) {
this.callback(level, msg);
this.callback(level, msg, this.timestamp());
callback(null, true);
};
......
......@@ -55,15 +55,17 @@ module.exports = function(dbConf, overConf, interfaces, httpLogs) {
}));
// The callback which write each new log message to websocket
logger.addCallbackLogs((level, msg) => {
logger.addCallbackLogs((level, msg, timestamp) => {
lastLogs.splice(0, Math.max(0, lastLogs.length - constants.WEBMIN_LOGS_CACHE + 1));
lastLogs.push({
timestamp: timestamp,
level: level,
msg: msg
});
wssEvents.broadcast(JSON.stringify({
type: 'log',
value: [{
timestamp: timestamp,
level: level,
msg: msg
}]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment