From 0bb574a8eb443e9a884ad28fab9c64aa592791cd Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Wed, 24 Mar 2021 23:10:37 +0900 Subject: [PATCH 1/3] Fix #496 Add clientOptions.logger option --- src/App.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/App.ts b/src/App.ts index a6902896f..37af11ab3 100644 --- a/src/App.ts +++ b/src/App.ts @@ -237,13 +237,21 @@ export default class App { this.logger.setLevel(this.logLevel); } this.errorHandler = defaultErrorHandler(this.logger); - this.clientOptions = { - agent, - // App propagates only the log level to WebClient as WebClient has its own logger - logLevel: this.logger.getLevel(), - tls: clientTls, - slackApiUrl: clientOptions !== undefined ? clientOptions.slackApiUrl : undefined, - }; + + this.clientOptions = clientOptions !== undefined ? clientOptions : {}; + if (agent !== undefined && this.clientOptions.agent === undefined) { + this.clientOptions.agent = agent; + } + if (clientTls !== undefined && this.clientOptions.tls === undefined) { + this.clientOptions.tls = clientTls; + } + if (logLevel !== undefined && logger === undefined) { + // If the constructor has both, logLevel is ignored + this.clientOptions.logLevel = logLevel; + } else { + // Since v3.4, WebClient starts sharing loggger with App + this.clientOptions.logger = this.logger; + } // the public WebClient instance (app.client) - this one doesn't have a token this.client = new WebClient(undefined, this.clientOptions); From 098d143fc4dd668f2ac074ad33b214a04f307860 Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Wed, 24 Mar 2021 23:16:42 +0900 Subject: [PATCH 2/3] Update codecov settings --- codecov.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/codecov.yml b/codecov.yml index 69942aa44..0b5e05855 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,2 +1,10 @@ ignore: - "examples/" # ignore examples folder and all its contents +coverage: + status: + project: + default: + threshold: 2.0% + patch: + default: + target: 50% From 4cf04d2e95b18b23d3b8d04e5b11ac7517c94116 Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Thu, 25 Mar 2021 07:24:34 +0900 Subject: [PATCH 3/3] Add warn logging --- src/App.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/App.ts b/src/App.ts index 37af11ab3..a17a9c949 100644 --- a/src/App.ts +++ b/src/App.ts @@ -246,9 +246,15 @@ export default class App { this.clientOptions.tls = clientTls; } if (logLevel !== undefined && logger === undefined) { - // If the constructor has both, logLevel is ignored + // only logLevel is passed this.clientOptions.logLevel = logLevel; } else { + if (logLevel !== undefined) { + // If the constructor has both, logLevel is ignored + this.logger.warn( + "As `logger` is passed as well, `logLevel` argument won't be used. Set the log level to the `logger` instance instead.", + ); + } // Since v3.4, WebClient starts sharing loggger with App this.clientOptions.logger = this.logger; }