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
+5 -5
View File
@@ -1,8 +1,8 @@
import debugModule from 'debug';
import logger from './logger.js';
import EventEmitter from 'node:events';
import safe from 'safetydance';
const debug = debugModule('box:asynctask');
const { log, trace } = logger('asynctask');
// this runs in-process
class AsyncTask extends EventEmitter {
@@ -20,16 +20,16 @@ class AsyncTask extends EventEmitter {
}
async start() { // should not throw!
debug(`start: ${this.name} started`);
log(`start: ${this.name} started`);
const [error] = await safe(this._run(this.#abortController.signal));
debug(`start: ${this.name} finished`);
log(`start: ${this.name} finished`);
this.emit('done', { errorMessage: error?.message || '' });
this.#abortController = null;
}
stop() {
if (this.#abortController === null) return; // already finished
debug(`stop: ${this.name} . sending abort signal`);
log(`stop: ${this.name} . sending abort signal`);
this.#abortController.abort();
}