diff --git a/src/lib/global-module.ts b/src/lib/global-module.ts index 72d9d25..016c73a 100644 --- a/src/lib/global-module.ts +++ b/src/lib/global-module.ts @@ -18,6 +18,7 @@ import { ConfigParser } from './parser'; import { ConfigFactory } from './factory'; import { ConfigValidator } from './validator'; import { CONFIG_LOGGER, CONFIG_OPTIONS } from '../tokens'; +import { ConfigLogger } from './logger'; @Global() @Module({ @@ -53,42 +54,40 @@ export class ConfigGlobalModule { if (!providers.find((provider) => provider.provide === CONFIG_LOGGER)) { providers.push({ provide: CONFIG_LOGGER, - useValue: console, + useClass: ConfigLogger, }); } providers.push( - ...[ - { - provide: CONFIG_OPTIONS, - useValue: options, - }, - { - provide: ConfigFacade, - inject: [ - ConfigExtractor, - ConfigParser, - ConfigFactory, - ConfigValidator, - CONFIG_LOGGER, - ], - useFactory: ( - configExtractor: ConfigExtractor, - configParser: ConfigParser, - configFactory: ConfigFactory, - configValidator: ConfigValidator, - logger: LoggerService, - ) => - new ConfigFacade( - configExtractor, - configParser, - configFactory, - configValidator, - logger, - options.fromFile, - ), - }, - ], + { + provide: CONFIG_OPTIONS, + useValue: options, + }, + { + provide: ConfigFacade, + inject: [ + ConfigExtractor, + ConfigParser, + ConfigFactory, + ConfigValidator, + CONFIG_LOGGER, + ], + useFactory: ( + configExtractor: ConfigExtractor, + configParser: ConfigParser, + configFactory: ConfigFactory, + configValidator: ConfigValidator, + logger: LoggerService, + ) => + new ConfigFacade( + configExtractor, + configParser, + configFactory, + configValidator, + logger, + options.fromFile, + ), + }, ); return { diff --git a/src/lib/logger.ts b/src/lib/logger.ts new file mode 100644 index 0000000..2839461 --- /dev/null +++ b/src/lib/logger.ts @@ -0,0 +1,14 @@ +/* eslint-disable */ +import { LoggerService } from '@nestjs/common'; + +export class ConfigLogger implements LoggerService { + log(message: any, context?: string): any {} + + error(message: any, trace?: string, context?: string): any {} + + warn(message: any, context?: string): any {} + + debug(message: any, context?: string): any {} + + verbose(message: any, context?: string): any {} +}