nest winston

Solutions on MaxInterview for nest winston by the best coders in the world

showing results for - "nest winston"
Ashley
27 Jan 2020
1// my.service.ts
2import { PinoLogger, InjectPinoLogger } from "nestjs-pino";
3
4@Injectable()
5export class MyService {
6  // regular injecting
7  constructor(private readonly logger: PinoLogger) {}
8
9  // regular injecting and set context
10  constructor(private readonly logger: PinoLogger) {
11    logger.setContext(MyService.name);
12  }
13
14  // inject and set context via `InjectPinoLogger`
15  constructor(
16    @InjectPinoLogger(MyService.name) private readonly logger: PinoLogger
17  ) {}
18
19  getWorld(...params: any[]) {
20    this.logger.info("getWorld(%o)", params);
21    return "World!";
22  }
23}