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:
@@ -1,10 +1,10 @@
|
||||
import assert from 'node:assert';
|
||||
import BoxError from '../boxerror.js';
|
||||
import debugModule from 'debug';
|
||||
import logger from '../logger.js';
|
||||
import os from 'node:os';
|
||||
import safe from 'safetydance';
|
||||
|
||||
const debug = debugModule('box:network/network-interface');
|
||||
const { log, trace } = logger('network/network-interface');
|
||||
|
||||
|
||||
async function getIPv4(config) {
|
||||
@@ -16,7 +16,7 @@ async function getIPv4(config) {
|
||||
|
||||
const addresses = iface.filter(i => i.family === 'IPv4').map(i => i.address);
|
||||
if (addresses.length === 0) throw new BoxError(BoxError.NETWORK_ERROR, `${config.ifname} does not have any IPv4 address`);
|
||||
if (addresses.length > 1) debug(`${config.ifname} has multiple ipv4 - ${JSON.stringify(addresses)}. choosing the first one.`);
|
||||
if (addresses.length > 1) log(`${config.ifname} has multiple ipv4 - ${JSON.stringify(addresses)}. choosing the first one.`);
|
||||
|
||||
return addresses[0];
|
||||
}
|
||||
@@ -30,7 +30,7 @@ async function getIPv6(config) {
|
||||
|
||||
const addresses = iface.filter(i => i.family === 'IPv6').map(i => i.address);
|
||||
if (addresses.length === 0) throw new BoxError(BoxError.NETWORK_ERROR, `${config.ifname} does not have any IPv6 address`);
|
||||
if (addresses.length > 1) debug(`${config.ifname} has multiple ipv6 - ${JSON.stringify(addresses)}. choosing the first one.`);
|
||||
if (addresses.length > 1) log(`${config.ifname} has multiple ipv6 - ${JSON.stringify(addresses)}. choosing the first one.`);
|
||||
|
||||
return addresses[0];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user