mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 11:47:09 +00:00
Replace console output by debug functions
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
const { listen } = require('../ws/db');
|
||||
const channels = require('../lib/db/channels');
|
||||
const handlers = require('./handlers').init();
|
||||
const { ERROR, INFO, DEBUG } = require('DOUGAL_ROOT/debug')(__filename);
|
||||
|
||||
function start () {
|
||||
listen(channels, async function (data) {
|
||||
DEBUG("Incoming data", data);
|
||||
for (const handler of handlers) {
|
||||
// NOTE: We are intentionally passing the same instance
|
||||
// of the data to every handler. This means that earlier
|
||||
@@ -15,7 +17,7 @@ function start () {
|
||||
}
|
||||
});
|
||||
|
||||
console.log("Events manager started.", handlers.length, "active handlers");
|
||||
INFO("Events manager started.", handlers.length, "active handlers");
|
||||
}
|
||||
|
||||
module.exports = { start }
|
||||
|
||||
@@ -5,6 +5,7 @@ const cfg = require("../lib/config");
|
||||
const { navdata } = require('../lib/db');
|
||||
const sendAlert = require("../lib/alerts");
|
||||
const headers = require('../lib/headers');
|
||||
const { ERROR, INFO, DEBUG } = require('DOUGAL_ROOT/debug')(__filename);
|
||||
|
||||
function maybeSendError(error, payload = {}) {
|
||||
const defaults = {
|
||||
@@ -100,22 +101,22 @@ for (const header of (cfg._("global.navigation.headers") || []).filter(h => h.ty
|
||||
});
|
||||
|
||||
server.on('message', (msg, rinfo) => {
|
||||
// console.log(`${header.type} :${header.port} ← ${msg.length} bytes from ${rinfo.address}:${rinfo.port}`);
|
||||
DEBUG(`${header.type} :${header.port} ← ${msg.length} bytes from ${rinfo.address}:${rinfo.port}`);
|
||||
|
||||
const navData = parseMessages(msg);
|
||||
|
||||
if (navData.payload.length) {
|
||||
navData.payload = navData.payload.reduce( (a, b) => Object.assign(a, b), {});
|
||||
delete navData.payload._type;
|
||||
// console.log("SAVE", JSON.stringify(navData, null, 4));
|
||||
// console.log("META", header.meta);
|
||||
// DEBUG("SAVE", JSON.stringify(navData, null, 4));
|
||||
// DEBUG("META", header.meta);
|
||||
navdata.save(navData, header.meta);
|
||||
}
|
||||
});
|
||||
|
||||
server.on('listening', () => {
|
||||
const address = server.address();
|
||||
console.log(`server listening ${address.address}:${address.port}`);
|
||||
INFO(`server listening ${address.address}:${address.port}`);
|
||||
});
|
||||
|
||||
server.bind(header.port);
|
||||
|
||||
Reference in New Issue
Block a user