nestjs-bunyan
v3.0.2
Published
Inject bunyan logger via decorator
Downloads
1,837
Readme
nestjs-bunyan
Inject bunyan logger via decorator
Usage
app.ts
@Module({
imports: [
BunyanLoggerModule.forRoot({
isGlobal: true,
isEnableRequestLogger: true,
bunyan: {
name: 'some awesome app',
},
}),
],
})
export class AppModule {}
some.controller.ts
@Controller()
export class SomeController {
@ReqLogger() private readonly logger: Bunyan
}
some.service.ts
import {Injectable} from '@nestjs/common'
@Injectable()
export class SomeService {
@Logger() private readonly logger: Bunyan
}
Customize Request Logger
app.ts
@Module({
imports: [
BunyanLoggerModule.forRoot({
isGlobal: true,
isEnableRequestLogger: true,
customRequestLogger(logger: Bunyan, req: Request) {
return logger.child({userId: req.session.uid})
},
bunyan: {
name: 'some awesome app',
},
}),
],
})
export class AppModule {}