use standard logger class in config.ts
This commit is contained in:
@@ -9,6 +9,7 @@ import { dirname, resolve } from 'node:path';
|
|||||||
import * as yaml from 'js-yaml';
|
import * as yaml from 'js-yaml';
|
||||||
import { globSync } from 'glob';
|
import { globSync } from 'glob';
|
||||||
import ipaddr from 'ipaddr.js';
|
import ipaddr from 'ipaddr.js';
|
||||||
|
import Logger from './logger.js';
|
||||||
import type * as Sentry from '@sentry/node';
|
import type * as Sentry from '@sentry/node';
|
||||||
import type * as SentryVue from '@sentry/vue';
|
import type * as SentryVue from '@sentry/vue';
|
||||||
import type { RedisOptions } from 'ioredis';
|
import type { RedisOptions } from 'ioredis';
|
||||||
@@ -155,6 +156,8 @@ type Source = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const configLogger = new Logger('config');
|
||||||
|
|
||||||
export type PrivateNetworkSource = string | { network?: string, ports?: number[] };
|
export type PrivateNetworkSource = string | { network?: string, ports?: number[] };
|
||||||
|
|
||||||
export type PrivateNetwork = {
|
export type PrivateNetwork = {
|
||||||
@@ -192,7 +195,7 @@ export function parsePrivateNetworks(patterns: PrivateNetworkSource[] | undefine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.warn('[config] Skipping invalid entry in allowedPrivateNetworks: ', e);
|
configLogger.warn('Skipping invalid entry in allowedPrivateNetworks: ', e);
|
||||||
return null;
|
return null;
|
||||||
})
|
})
|
||||||
.filter(p => p != null);
|
.filter(p => p != null);
|
||||||
@@ -375,12 +378,12 @@ export function loadConfig(): Config {
|
|||||||
|
|
||||||
if (configFiles.length === 0
|
if (configFiles.length === 0
|
||||||
&& !process.env['MK_WARNED_ABOUT_CONFIG']) {
|
&& !process.env['MK_WARNED_ABOUT_CONFIG']) {
|
||||||
console.log('No config files loaded, check if this is intentional');
|
configLogger.warn('No config files loaded, check if this is intentional');
|
||||||
process.env['MK_WARNED_ABOUT_CONFIG'] = '1';
|
process.env['MK_WARNED_ABOUT_CONFIG'] = '1';
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = configFiles.map(path => {
|
const config = configFiles.map(path => {
|
||||||
console.log(`Reading configuration from ${path}`);
|
configLogger.info(`Reading configuration from ${path}`);
|
||||||
return fs.readFileSync(path, 'utf-8');
|
return fs.readFileSync(path, 'utf-8');
|
||||||
})
|
})
|
||||||
.map(contents => yaml.load(contents) as Source)
|
.map(contents => yaml.load(contents) as Source)
|
||||||
|
|||||||
Reference in New Issue
Block a user