Skip to content

Commit 5a3c8b4

Browse files
committed
Fix logger.
1 parent df9dd9d commit 5a3c8b4

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

packages/sdk/browser/src/BrowserClient.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
BasicLogger,
55
LDClient as CommonClient,
66
Configuration,
7+
createSafeLogger,
78
Encoding,
89
FlagManager,
910
internal,
@@ -52,12 +53,18 @@ export class BrowserClient extends LDClientImpl {
5253
overridePlatform?: Platform,
5354
) {
5455
const { logger: customLogger, debug } = options;
56+
// Overrides the default logger from the common implementation.
5557
const logger =
5658
customLogger ??
57-
new BasicLogger({
58-
level: debug ? 'debug' : 'info',
59+
createSafeLogger({
5960
// eslint-disable-next-line no-console
60-
destination: console.log,
61+
debug: debug ? console.debug : () => {},
62+
// eslint-disable-next-line no-console
63+
info: console.info,
64+
// eslint-disable-next-line no-console
65+
warn: console.warn,
66+
// eslint-disable-next-line no-console
67+
error: console.error,
6168
});
6269

6370
// TODO: Use the already-configured baseUri from the SDK config. SDK-560
@@ -70,7 +77,7 @@ export class BrowserClient extends LDClientImpl {
7077
clientSideId,
7178
autoEnvAttributes,
7279
platform,
73-
filterToBaseOptions(options),
80+
filterToBaseOptions({ ...options, logger }),
7481
(
7582
flagManager: FlagManager,
7683
configuration: Configuration,

packages/sdk/browser/src/BrowserDataManager.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ export default class BrowserDataManager extends BaseDataManager {
117117
}
118118

119119
private stopDataSource() {
120+
if (this.updateProcessor) {
121+
this.debugLog('Stopping update processor.');
122+
}
120123
this.updateProcessor?.close();
121124
this.updateProcessor = undefined;
122125
}

0 commit comments

Comments
 (0)