1.1.2 • Published 1 year ago
@habibovulugbek/logger v1.1.2
Logger for NestJS
Before installation
If you want to use Logger
, you must install additional packages:
$ npm install --save @nestjs/common @habibovulugbek/logger
Getting started
HttpLoggerInterceptor
You can use HttpLoggerInterceptor
in your main.ts
file to represent your request and response.
// main.ts
import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
import { HttpLoggerInterceptor } from '@habibovulugbek/logger'
async function bootstrap() {
const app = await NestFactory.create(AppModule)
app.useGlobalInterceptors(new HttpLoggerInterceptor())
await app.listen(3000)
}
RpcLoggingInterceptor
You can use RpcLoggingInterceptor
in your main.ts
file to represent your request and response.
//main.ts
import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
import { RpcLoggingInterceptor } from '@habibovulugbek/logger'
async function bootstrap() {
const app = await NestFactory.createMicroservice(AppModule, {
transport: Transport.TCP,
options: {
host: '127.0.0.1',
port: 3000,
},
})
app.useGlobalInterceptors(new RpcLoggingInterceptor())
await app.listenAsync()
}
bootstrap()
Enjoy!