You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there an existing issue that is already proposing this?
I have searched the existing issues
Is your feature request related to a problem? Please describe it
There is no way to provide a custom logger that has injectable dependencies since you can't provide those providers (other modules, etc) to Terminus when calling TerminusModule.forRoot()
Terminus is just taking the class-type and passing it as a useClass provider.
Describe the solution you'd like
It would be useful if the terminus module could default to using the Nest provided logger, which can be overridden when doing app.useLogger. This would allow for custom loggers an application is using to just be re-used by Terminus without any additional configuration.
Alternatively, the options to TerminusModule.forRoot could be enhanced to be able to provide the dependencies needed to create an instance of the custom logger.
What is the motivation / use case for changing the behavior?
I have a custom LoggerModule that exports a LoggerService that re-uses a single Pino logger instance. This LoggerService's dependencies, in addition to the pino logger, also has some stuff in it for AsyncContext storage management to enhance logs, but the main priority is that the entire log needs to be in JSON format to be ingested by Humio in the format expected for structured logging, which my custom logger handles.
Currently Terminus's errorLogStyle doesn't change the entire log to JSON but only the details
[Nest] 64381 - 05/01/2024, 11:48:10 AM ERROR [HealthCheckService] Health Check has failed! {"rabbitmq":{"status":"up","uri":"amqp://localhost:5672"},"postgres":{"status":"down"}}
Sorry for the late response. I've implemented a version where we'd use the default logger, hence you can overwrite it with app.useLogger(...). Would you like to verify my implementation by installing the latest beta? npm -i --save @nestjs/terminus@beta?
Hi @BrunnerLivio, I installed the beta version "10.3.0-beta.0" in my project and tested if it uses the global defined Logger (LoggerService). It works as expected 👍 .
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
There is no way to provide a custom logger that has injectable dependencies since you can't provide those providers (other modules, etc) to Terminus when calling
TerminusModule.forRoot()
Terminus is just taking the class-type and passing it as a
useClass
provider.Describe the solution you'd like
It would be useful if the terminus module could default to using the Nest provided logger, which can be overridden when doing
app.useLogger
. This would allow for custom loggers an application is using to just be re-used by Terminus without any additional configuration.Alternatively, the options to
TerminusModule.forRoot
could be enhanced to be able to provide the dependencies needed to create an instance of the custom logger.Teachability, documentation, adoption, migration strategy
If the first suggestion is adopted, users wouldn't have to change anything about how they declare
TerminusModule
.If a different approach is chosen, maybe it could look like
What is the motivation / use case for changing the behavior?
I have a custom
LoggerModule
that exports aLoggerService
that re-uses a single Pino logger instance. ThisLoggerService
's dependencies, in addition to the pino logger, also has some stuff in it for AsyncContext storage management to enhance logs, but the main priority is that the entire log needs to be in JSON format to be ingested by Humio in the format expected for structured logging, which my custom logger handles.Currently Terminus's
errorLogStyle
doesn't change the entire log to JSON but only the detailsbut that should really look like
in my case.
The text was updated successfully, but these errors were encountered: