diff --git a/Tutorial.md b/Tutorial.md index 7d989f4..337fe01 100644 --- a/Tutorial.md +++ b/Tutorial.md @@ -1,5 +1,21 @@ In this page, we'll provide a guide to learn how to use NestLogged package. +# Setup + +Since `v3.3.0`, you should put `ConsoleLogger` exported from nestlogged package to the `NestFactory.create` call. +```ts +import { ConsoleLogger } from 'nestlogged'; + +const app = await NestFactory.create(AppModule, { + logger: new ConsoleLogger(), +}); +``` + +The definition of ConsoleLogger is 100% same with ConsoleLogger from `@nestjs/common`, so you can just use it normally. + +This new ConsoleLogger handles additional request scope parameter internally. + + # Method Logging ## Basic @@ -86,4 +102,13 @@ export function LoggedRoute, R>( options?: Partial ) { ... -} \ No newline at end of file +} +``` + +## Logger Initialization + +For LoggedFunction and LoggedRoute decorator, it will initialize new `ScopedLogger` if it does not exists as `logger` property in the class. This initialization is processed on the first call of decorated function. + +`ScopedLogger` is the new class extending `Logger` from `@nestjs/common`, adding ability to add scope and scope id to each logs. But you don't have to worry about it, it's not a whole new system. It's completely same as usual logging, and internal code will do all the "scope" processes. + +If you want to know more about scoped logging, check Logger Injection & Scoped Logging. \ No newline at end of file