nestjs-bunyan
TypeScript icon, indicating that this package has built-in type declarations

3.0.2 • Public • Published

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 {}

Readme

Keywords

none

Package Sidebar

Install

npm i nestjs-bunyan

Weekly Downloads

335

Version

3.0.2

License

none

Unpacked Size

17.5 kB

Total Files

14

Last publish

Collaborators

  • bangbang93