import { Controller , Get , Logger } from "@nestjs/common" ; import { MyService } from "./my.service" ; import { InjectPinoLogger , PinoLogger } from "../src" ; @ Controller ( ) export class AppController { private readonly builtInLogger = new Logger ( AppController . name ) ; constructor ( private readonly myService , @ InjectPinoLogger ( AppController . name ) private readonly pinoLogger1 , private readonly pinoLogger2 ) { pinoLogger2 . setContext ( AppController . name ) ; } @ Get ( ) getHello ( ) { this . builtInLogger . verbose ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; this . builtInLogger . debug ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; this . builtInLogger . log ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; this . builtInLogger . warn ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; this . builtInLogger . error ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; this . pinoLogger1 . trace ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; this . pinoLogger1 . debug ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; this . pinoLogger1 . info ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; this . pinoLogger1 . warn ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; this . pinoLogger1 . error ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; this . pinoLogger1 . fatal ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; this . pinoLogger2 . trace ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; this . pinoLogger2 . debug ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; this . pinoLogger2 . info ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; this . pinoLogger2 . warn ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; this . pinoLogger2 . error ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; this . pinoLogger2 . fatal ( { foo : 'bar' } , 'baz %s' , 'qux' ) ; return `Hello ${ this . myService . getWorld ( ) }` ; } }