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:
+6
-6
@@ -2,7 +2,7 @@ import assert from 'node:assert';
|
||||
import BoxError from './boxerror.js';
|
||||
import crypto from 'node:crypto';
|
||||
import database from './database.js';
|
||||
import debugModule from 'debug';
|
||||
import logger from './logger.js';
|
||||
import eventlog from './eventlog.js';
|
||||
import mounts from './mounts.js';
|
||||
import path from 'node:path';
|
||||
@@ -10,7 +10,7 @@ import paths from './paths.js';
|
||||
import safe from 'safetydance';
|
||||
import services from './services.js';
|
||||
|
||||
const debug = debugModule('box:volumes');
|
||||
const { log, trace } = logger('volumes');
|
||||
|
||||
const VOLUMES_FIELDS = [ 'id', 'name', 'hostPath', 'creationTime', 'mountType', 'mountOptionsJson' ].join(',');
|
||||
|
||||
@@ -87,7 +87,7 @@ async function add(volume, auditSource) {
|
||||
|
||||
await eventlog.add(eventlog.ACTION_VOLUME_ADD, auditSource, { id, name, hostPath });
|
||||
// in theory, we only need to do this mountpoint volumes. but for some reason a restart is required to detect new "mounts"
|
||||
safe(services.rebuildService('sftp', auditSource), { debug });
|
||||
safe(services.rebuildService('sftp', auditSource), { debug: log });
|
||||
|
||||
return id;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ async function update(volume, mountOptions, auditSource) {
|
||||
await database.query('UPDATE volumes SET hostPath=?,mountOptionsJson=? WHERE id=?', [ hostPath, JSON.stringify(mountOptions), volume.id ]);
|
||||
await eventlog.add(eventlog.ACTION_VOLUME_UPDATE, auditSource, { id: volume.id, name, hostPath });
|
||||
// in theory, we only need to do this mountpoint volumes. but for some reason a restart is required to detect new "mounts"
|
||||
safe(services.rebuildService('sftp', auditSource), { debug });
|
||||
safe(services.rebuildService('sftp', auditSource), { debug: log });
|
||||
}
|
||||
|
||||
async function list() {
|
||||
@@ -187,14 +187,14 @@ async function del(volume, auditSource) {
|
||||
await eventlog.add(eventlog.ACTION_VOLUME_REMOVE, auditSource, { ...volume });
|
||||
|
||||
if (volume.mountType === mounts.MOUNT_TYPE_MOUNTPOINT || volume.mountType === mounts.MOUNT_TYPE_FILESYSTEM) {
|
||||
safe(services.rebuildService('sftp', auditSource), { debug });
|
||||
safe(services.rebuildService('sftp', auditSource), { debug: log });
|
||||
} else {
|
||||
await safe(mounts.removeMount(volume));
|
||||
}
|
||||
}
|
||||
|
||||
async function mountAll() {
|
||||
debug('mountAll: mouting all volumes');
|
||||
log('mountAll: mouting all volumes');
|
||||
|
||||
for (const volume of await list()) {
|
||||
if (volume.mountType === mounts.MOUNT_TYPE_MOUNTPOINT || volume.mountType === mounts.MOUNT_TYPE_FILESYSTEM) continue;
|
||||
|
||||
Reference in New Issue
Block a user