diff --git a/examples/replace-nest-logger-bootstrap/package.json b/examples/replace-nest-logger-bootstrap/package.json index 33d9795..20a966d 100644 --- a/examples/replace-nest-logger-bootstrap/package.json +++ b/examples/replace-nest-logger-bootstrap/package.json @@ -24,7 +24,7 @@ "@nestjs/common": "10.3.0", "@nestjs/core": "10.3.0", "@nestjs/platform-express": "10.3.0", - "@wildegor/nestjs-prologger": "1.0.5", + "@wildegor/nestjs-prologger": "1.0.0", "reflect-metadata": "0.2.1", "rimraf": "3.0.2", "rxjs": "6.6.7", diff --git a/examples/replace-nest-logger-bootstrap/src/app.module.ts b/examples/replace-nest-logger-bootstrap/src/app.module.ts index 61bfb8c..5b5307a 100644 --- a/examples/replace-nest-logger-bootstrap/src/app.module.ts +++ b/examples/replace-nest-logger-bootstrap/src/app.module.ts @@ -1,10 +1,16 @@ import { Module, Logger } from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; +import { LoggerModule } from '@wildegor/nestjs-prologger'; +import { ConfigModule } from './infrastructure/configs/config.module'; +import { LoggerConfig } from './infrastructure/configs/logger.config'; @Module({ imports: [ - + ConfigModule, + LoggerModule.forRootAsync({ + useExisting: LoggerConfig, + }), ], controllers: [AppController], providers: [AppService, Logger], diff --git a/examples/replace-nest-logger-bootstrap/src/infrastructure/configs/config.module.ts b/examples/replace-nest-logger-bootstrap/src/infrastructure/configs/config.module.ts new file mode 100644 index 0000000..1a3819f --- /dev/null +++ b/examples/replace-nest-logger-bootstrap/src/infrastructure/configs/config.module.ts @@ -0,0 +1,9 @@ +import { Global, Module } from '@nestjs/common'; +import { LoggerConfig } from './logger.config'; + +@Global() +@Module({ + providers: [LoggerConfig], + exports: [LoggerConfig], +}) +export class ConfigModule {} diff --git a/examples/replace-nest-logger-bootstrap/src/infrastructure/configs/logger.config.ts b/examples/replace-nest-logger-bootstrap/src/infrastructure/configs/logger.config.ts new file mode 100644 index 0000000..0ae790d --- /dev/null +++ b/examples/replace-nest-logger-bootstrap/src/infrastructure/configs/logger.config.ts @@ -0,0 +1,30 @@ +import { Injectable } from '@nestjs/common'; +import { + ILoggerModuleOptions, + ILoggerOptions, +} from '@wildegor/nestjs-prologger/modules/infrastructure/interfaces/logger.interfaces'; +import { ILoggerConfigFactory } from '@wildegor/nestjs-prologger/modules/modules/logger/logger.interfaces'; + +@Injectable() +export class LoggerConfig implements ILoggerConfigFactory { + private readonly _opts: ILoggerOptions; + + constructor() { + this._opts = { + hideTrace: false, + meta: { + organization: 'NestJS ProLogger', + context: 'service', + app: 'example', + }, + }; + } + + public createLoggerConfig(): + | ILoggerModuleOptions + | Promise { + return { + opts: this._opts, + }; + } +} diff --git a/examples/replace-nest-logger-bootstrap/src/main.ts b/examples/replace-nest-logger-bootstrap/src/main.ts index ad7b4db..a74dcd2 100644 --- a/examples/replace-nest-logger-bootstrap/src/main.ts +++ b/examples/replace-nest-logger-bootstrap/src/main.ts @@ -1,10 +1,17 @@ import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; +import { LoggerConstants } from '@wildegor/nestjs-prologger/modules/modules/logger/logger.constants'; +import { LoggerAdapter } from '@wildegor/nestjs-prologger/modules/modules/logger/logger.adapter'; async function bootstrap() { const app = await NestFactory.create(AppModule, { // logger: , // TODO }); + + const logger = app.get(LoggerConstants.logger); + + logger.log('TEST'); + await app.listen(3000); } bootstrap(); diff --git a/examples/replace-nest-logger-bootstrap/yarn.lock b/examples/replace-nest-logger-bootstrap/yarn.lock index b63fa00..864b4ee 100644 --- a/examples/replace-nest-logger-bootstrap/yarn.lock +++ b/examples/replace-nest-logger-bootstrap/yarn.lock @@ -1252,10 +1252,10 @@ "@webassemblyjs/ast" "1.11.6" "@xtuc/long" "4.2.2" -"@wildegor/nestjs-prologger@1.0.5": - version "1.0.5" - resolved "https://npm.pkg.github.com/download/@wildegor/nestjs-prologger/1.0.5/fb7ae0179c3202f0a03189232b4eed39098e481d#fb7ae0179c3202f0a03189232b4eed39098e481d" - integrity sha512-a9ftmHf1M/HBvnmCwBMvQ6QhcCPFla9y/07B6xX39n+gduJjVDgmvCmekqL6zOI8+lPXVUs6z6FqGAeKNFGe0g== +"@wildegor/nestjs-prologger@1.0.0": + version "1.0.0" + resolved "https://npm.pkg.github.com/download/@wildegor/nestjs-prologger/1.0.0/33064c3109cf7522da37a2900744ac0d9ec2a336#33064c3109cf7522da37a2900744ac0d9ec2a336" + integrity sha512-SHfaIRru1C3r+dwnCutOSJmNL0hO68XvUXgD0TEHZ/0S7sFiS0Lq+bbMD5eHkmLKcB+4vzL0gm0ViVMRZM9M0A== "@xtuc/ieee754@^1.2.0": version "1.2.0" diff --git a/src/modules/context/context.module.ts b/src/modules/context/context.module.ts index 0f0680a..887834e 100644 --- a/src/modules/context/context.module.ts +++ b/src/modules/context/context.module.ts @@ -25,14 +25,18 @@ import { ContextRepository } from './context.repository'; }, }), ], - controllers: [], providers: [ { provide: ContextConstants.contextRepository, useClass: ContextRepository, }, ], - exports: [ContextConstants.contextRepository], + exports: [ + { + provide: ContextConstants.contextRepository, + useClass: ContextRepository, + }, + ], }) export class ContextModule { }