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
+16
View File
@@ -0,0 +1,16 @@
import util from 'node:util';
const TRACE_ENABLED = false;
const LOG_ENABLED = process.env.BOX_ENV !== 'test' || !!process.env.LOG;
function output(namespace, args) {
const ts = new Date().toISOString();
process.stdout.write(`${ts} ${namespace}: ${util.format(...args)}\n`);
}
export default function logger(namespace) {
return {
log: LOG_ENABLED ? (...args) => output(namespace, args) : () => {},
trace: TRACE_ENABLED ? (...args) => output(namespace, args) : () => {},
};
}