-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogger.js
More file actions
31 lines (29 loc) · 774 Bytes
/
Copy pathlogger.js
File metadata and controls
31 lines (29 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use strict';
module.exports = class Logger {
constructor(app) {
this.app = app;
}
//Send logs over MQTT
log(){
let currentTime = "-";
if(this.app.intelligence.startTime) {
currentTime = new Date().getTime() - this.app.intelligence.startTime;
}
let message = "["+currentTime+"] ";
for(let arg of arguments) {
if(typeof arg === 'object') {
message += JSON.stringify(arg);
}
else {
message += arg;
}
message += " ";
}
console.log(message);
this.app.mqttServer.publish({
topic: '/logs',
payload: message,
qos: 0, retain: false
});
}
}