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:
@@ -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) : () => {},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user