Closed KyleBrown-804 closed 4 months ago
NestJS built-in logger cannot be extended by design. It has only a specific amount of methods and that's it. That's why this library consists of 2 loggers. One is the idiomatic NestJS logger implementation used for substitution under the hood when using the built-in logger. The second one is used for specific features and could be extended and injected where needed.
Question Context: I figured out from a previous question how I could extend functionality from the Logger or PinoLogger from 'nestjs-pino' here: https://github.com/iamolegga/nestjs-pino/issues/391 and I can see how example of what's added in #441 should work with what I want, which is to add a new method let's call it "serviceError()". I want to add some additional logic and metadata to certain error logs and that method will then invoke
super.error()
.Part I'm not understanding: What I haven't figured out from also looking at the example in the readme for usage, is how I could actually access this added method "serviceError()" from the logger if in my service I am importing
import { Logger } from '@nestjs/common
. That logger doesn't have the added method so just trying to understand how I could use methods from an extended logger so that I can usethis.logger.serviceError()
in place ofthis.logger.error()
in a service.Please mention other relevant information such as Node.js version and Operating System.