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
+8 -8
View File
@@ -4,7 +4,7 @@ import asynctask from './asynctask.js';
const { AsyncTask } = asynctask;
import backupSites from './backupsites.js';
import BoxError from './boxerror.js';
import debugModule from 'debug';
import logger from './logger.js';
import df from './df.js';
import docker from './docker.js';
import eventlog from './eventlog.js';
@@ -18,7 +18,7 @@ import safe from 'safetydance';
import shellModule from './shell.js';
import volumes from './volumes.js';
const debug = debugModule('box:system');
const { log, trace } = logger('system');
const shell = shellModule('system');
@@ -168,7 +168,7 @@ async function getFilesystems() {
}
async function checkDiskSpace() {
debug('checkDiskSpace: checking disk space');
log('checkDiskSpace: checking disk space');
const filesystems = await getFilesystems();
@@ -185,7 +185,7 @@ async function checkDiskSpace() {
}
}
debug(`checkDiskSpace: disk space checked. low disk space: ${markdownMessage || 'no'}`);
log(`checkDiskSpace: disk space checked. low disk space: ${markdownMessage || 'no'}`);
if (markdownMessage) {
const finalMessage = `One or more file systems are running low on space. Please increase the disk size at the earliest.\n\n${markdownMessage}`;
@@ -223,7 +223,7 @@ class FilesystemUsageTask extends AsyncTask {
if (type === 'ext4' || type === 'xfs') { // hdparm only works with block devices
this.emitProgress(percent, 'Calculating Disk Speed');
const [speedError, speed] = await safe(hdparm(filesystem, { abortSignal }));
if (speedError) debug(`hdparm error ${filesystem}: ${speedError.message}`);
if (speedError) log(`hdparm error ${filesystem}: ${speedError.message}`);
this.emitData({ speed: speedError ? -1 : speed });
} else {
this.emitData({ speed: -1 });
@@ -241,7 +241,7 @@ class FilesystemUsageTask extends AsyncTask {
content.usage = content.id === 'docker' ? dockerDf.LayersSize : dockerDf.Volumes.map((v) => v.UsageData.Size).reduce((a,b) => a + b, 0);
} else {
const [error, duResult] = await safe(du(content.path, { abortSignal }));
if (error) debug(`du error ${content.path}: ${error.message}`); // can happen if app is installing etc
if (error) log(`du error ${content.path}: ${error.message}`); // can happen if app is installing etc
content.usage = duResult || 0;
}
usage += content.usage;
@@ -266,7 +266,7 @@ async function reboot() {
await notifications.unpin(notifications.TYPE_REBOOT, {});
const [error] = await safe(shell.sudo([ REBOOT_CMD ], {}));
if (error) debug('reboot: could not reboot. %o', error);
if (error) log('reboot: could not reboot. %o', error);
}
async function getInfo() {
@@ -369,7 +369,7 @@ async function checkUbuntuVersion() {
}
async function runSystemChecks() {
debug('runSystemChecks: checking status');
log('runSystemChecks: checking status');
const checks = [
checkRebootRequired(),