From dabd2cfee89fc85348f2e8441b7fb57348e95fda Mon Sep 17 00:00:00 2001 From: Zoe Codez Date: Thu, 14 Nov 2024 17:23:39 -0600 Subject: [PATCH] do not load files --- src/helpers/wiring.mts | 4 +--- src/services/configuration.service.mts | 22 ++++++++++++---------- src/services/logger.service.mts | 16 ++++++++++++---- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/helpers/wiring.mts b/src/helpers/wiring.mts index c8aed61..dcadc5c 100644 --- a/src/helpers/wiring.mts +++ b/src/helpers/wiring.mts @@ -141,10 +141,8 @@ export type TInjectedConfig = { // #region Special // SEE DOCS http://docs.digital-alchemy.app/docs/core/declaration-merging -// eslint-disable-next-line @typescript-eslint/no-empty-object-type export interface AsyncLogData { - // No data by default - // Intended to have declaration merges happen to be useful + logger: ILogger; } export interface AsyncLocalData { diff --git a/src/services/configuration.service.mts b/src/services/configuration.service.mts index b7342aa..89accc2 100644 --- a/src/services/configuration.service.mts +++ b/src/services/configuration.service.mts @@ -137,16 +137,18 @@ export function Configuration({ }), ["env", "argv"], ); - mergeConfig( - await configLoaderFile({ - application, - configs: configDefinitions, - internal, - logger, - }), - ["file"], - ); - + const canFile = internal.boot.options?.configSources?.file ?? true; + if (canFile) { + mergeConfig( + await configLoaderFile({ + application, + configs: configDefinitions, + internal, + logger, + }), + ["file"], + ); + } // * load! await eachSeries([...loaders.entries()], async ([type, loader]) => { mergeConfig(await loader({ application, configs: configDefinitions, internal, logger }), [ diff --git a/src/services/logger.service.mts b/src/services/logger.service.mts index 925dd28..b7dc99f 100644 --- a/src/services/logger.service.mts +++ b/src/services/logger.service.mts @@ -76,7 +76,7 @@ export async function Logger({ }); } - function mergeData(data: T): T { + function mergeData(data: T): [T, ILogger] { let out = { ...data, ...loggerOptions.mergeData }; if (loggerOptions.counter) { @@ -84,11 +84,15 @@ export async function Logger({ counter.logIdx = logCounter++; } + let logger: ILogger; if (loggerOptions.als) { - out = { ...out, ...als.getLogData() }; + const data = als.getLogData(); + logger = data.logger; + delete data.logger; + out = { ...out, ...data }; } - return out; + return [out, logger]; } const prettyFormatMessage = (message: string): string => { @@ -122,7 +126,7 @@ export async function Logger({ [...METHOD_COLORS.keys()].forEach(key => { const level = `[${key.toUpperCase()}]`.padStart(LEVEL_MAX, " "); logger[key] = (context: TContext, ...parameters: Parameters) => { - const data = mergeData( + const [data, child] = mergeData( is.object(parameters[FIRST]) ? (parameters.shift() as { context?: TContext; @@ -185,6 +189,10 @@ export async function Logger({ .slice(SYMBOL_START, SYMBOL_END) .join("\n"); } + if (child) { + child[key](message); + return; + } switch (key) { case "warn": { globalThis.console.warn(message);