replace debug() with our custom logger

mostly we want trace() and log(). trace() can be enabled whenever
we want by flipping a flag and restarting box
This commit is contained in:
Girish Ramakrishnan
2026-03-12 22:55:28 +05:30
parent d57554a48c
commit 01d0c738bc
104 changed files with 1187 additions and 1174 deletions

14
box.js
View File

@@ -10,9 +10,9 @@ import proxyAuth from './src/proxyauth.js';
import safe from 'safetydance';
import server from './src/server.js';
import directoryServer from './src/directoryserver.js';
import debugModule from 'debug';
import logger from './src/logger.js';
const debug = debugModule('box:box');
const { log, trace } = logger('box');
let logFd;
@@ -59,13 +59,13 @@ const [error] = await safe(startServers());
if (error) exitSync({ error, code: 1, message: 'Error starting servers' });
process.on('SIGHUP', async function () {
debug('Received SIGHUP. Re-reading configs.');
log('Received SIGHUP. Re-reading configs.');
const conf = await directoryServer.getConfig();
if (conf.enabled) await directoryServer.checkCertificate();
});
process.on('SIGINT', async function () {
debug('Received SIGINT. Shutting down.');
log('Received SIGINT. Shutting down.');
await proxyAuth.stop();
await server.stop();
@@ -74,13 +74,13 @@ process.on('SIGINT', async function () {
await oidcServer.stop();
setTimeout(() => {
debug('Shutdown complete');
log('Shutdown complete');
process.exit();
}, 2000); // need to wait for the task processes to die
});
process.on('SIGTERM', async function () {
debug('Received SIGTERM. Shutting down.');
log('Received SIGTERM. Shutting down.');
await proxyAuth.stop();
await server.stop();
@@ -89,7 +89,7 @@ process.on('SIGTERM', async function () {
await oidcServer.stop();
setTimeout(() => {
debug('Shutdown complete');
log('Shutdown complete');
process.exit();
}, 2000); // need to wait for the task processes to die
});