Update Tutorial
parent
4848425075
commit
9539d633ca
25
Tutorial.md
25
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
|
||||
@ -87,3 +103,12 @@ export function LoggedRoute<F extends Array<any>, R>(
|
||||
) {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
## 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.
|
Loading…
x
Reference in New Issue
Block a user