From 92740566d3476694b31c2fda72bdbf6e6e099568 Mon Sep 17 00:00:00 2001 From: Mikael Langer Date: Mon, 20 Mar 2023 08:48:06 +0100 Subject: [PATCH] fix: missing setContext when using logger: false HealthIndicator assumes it gets a ConsoleLogger, but TERMINUS_LOGGER is only guaranteed to be an instance of LoggerService which doesn't have a setContext method. This breaks when using logger: false. --- lib/health-indicator/http/http.health.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/health-indicator/http/http.health.ts b/lib/health-indicator/http/http.health.ts index c77abe194..ae37184c5 100644 --- a/lib/health-indicator/http/http.health.ts +++ b/lib/health-indicator/http/http.health.ts @@ -33,7 +33,9 @@ export class HttpHealthIndicator extends HealthIndicator { private readonly logger: ConsoleLogger, ) { super(); - this.logger.setContext(HttpHealthIndicator.name); + if (this.logger instanceof ConsoleLogger) { + this.logger.setContext(HttpHealthIndicator.name); + } this.checkDependantPackages(); }