@featbit/js-client-sdk 3.0.11 → 3.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +301 -301
- package/dist/esm/FbClientCore.d.ts.map +1 -1
- package/dist/esm/FbClientCore.js +1 -1
- package/dist/esm/FbClientCore.js.map +1 -1
- package/dist/esm/data-sources/DataSourceUpdates.d.ts +2 -2
- package/dist/esm/data-sources/DataSourceUpdates.d.ts.map +1 -1
- package/dist/esm/data-sources/DataSourceUpdates.js +55 -51
- package/dist/esm/data-sources/DataSourceUpdates.js.map +1 -1
- package/dist/esm/data-sources/createStreamListeners.d.ts +0 -9
- package/dist/esm/data-sources/createStreamListeners.d.ts.map +1 -1
- package/dist/esm/data-sources/createStreamListeners.js +10 -10
- package/dist/esm/data-sources/createStreamListeners.js.map +1 -1
- package/dist/esm/data-sync/IDataSynchronizer.d.ts +1 -1
- package/dist/esm/data-sync/IDataSynchronizer.d.ts.map +1 -1
- package/dist/esm/data-sync/NullDataSynchronizer.d.ts +1 -1
- package/dist/esm/data-sync/NullDataSynchronizer.d.ts.map +1 -1
- package/dist/esm/data-sync/NullDataSynchronizer.js +11 -0
- package/dist/esm/data-sync/NullDataSynchronizer.js.map +1 -1
- package/dist/esm/data-sync/PollingDataSynchronizer.d.ts +1 -1
- package/dist/esm/data-sync/PollingDataSynchronizer.d.ts.map +1 -1
- package/dist/esm/data-sync/PollingDataSynchronizer.js +42 -17
- package/dist/esm/data-sync/PollingDataSynchronizer.js.map +1 -1
- package/dist/esm/data-sync/WebSocketDataSynchronizer.d.ts +2 -1
- package/dist/esm/data-sync/WebSocketDataSynchronizer.d.ts.map +1 -1
- package/dist/esm/data-sync/WebSocketDataSynchronizer.js +20 -6
- package/dist/esm/data-sync/WebSocketDataSynchronizer.js.map +1 -1
- package/dist/esm/data-sync/types.d.ts +1 -1
- package/dist/esm/data-sync/types.d.ts.map +1 -1
- package/dist/esm/integrations/test_data/TestDataSynchronizer.d.ts +1 -1
- package/dist/esm/integrations/test_data/TestDataSynchronizer.d.ts.map +1 -1
- package/dist/esm/integrations/test_data/TestDataSynchronizer.js +3 -1
- package/dist/esm/integrations/test_data/TestDataSynchronizer.js.map +1 -1
- package/dist/esm/platform/browser/BrowserWebSocket.d.ts.map +1 -1
- package/dist/esm/platform/browser/BrowserWebSocket.js +4 -0
- package/dist/esm/platform/browser/BrowserWebSocket.js.map +1 -1
- package/dist/esm/store/IDataSourceUpdates.d.ts +2 -2
- package/dist/esm/store/IDataSourceUpdates.d.ts.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/{featbit-js-client-sdk-3.0.11.js → featbit-js-client-sdk-3.0.13.js} +2 -2
- package/dist/umd/featbit-js-client-sdk-3.0.13.js.map +1 -0
- package/dist/umd/featbit-js-client-sdk.js +1 -1
- package/dist/umd/featbit-js-client-sdk.js.map +1 -1
- package/package.json +46 -46
- package/src/Configuration.ts +232 -232
- package/src/Context.ts +61 -61
- package/src/FbClientBuilder.ts +167 -167
- package/src/FbClientCore.ts +405 -401
- package/src/IContextProperty.ts +3 -3
- package/src/IDataKind.ts +11 -11
- package/src/IFbClient.ts +29 -29
- package/src/IFbClientCore.ts +290 -290
- package/src/IVersionedData.ts +18 -18
- package/src/bootstrap/IBootstrapProvider.ts +4 -4
- package/src/bootstrap/JsonBootstrapProvider.ts +34 -34
- package/src/bootstrap/NullBootstrapProvider.ts +20 -20
- package/src/bootstrap/index.ts +2 -2
- package/src/constants.ts +1 -1
- package/src/data-sources/DataSourceUpdates.ts +116 -116
- package/src/data-sources/createStreamListeners.ts +67 -66
- package/src/data-sources/index.ts +1 -1
- package/src/data-sync/DataSyncMode.ts +3 -3
- package/src/data-sync/IDataSynchronizer.ts +15 -15
- package/src/data-sync/IRequestor.ts +10 -10
- package/src/data-sync/NullDataSynchronizer.ts +14 -14
- package/src/data-sync/PollingDataSynchronizer.ts +125 -111
- package/src/data-sync/Requestor.ts +61 -61
- package/src/data-sync/WebSocketDataSynchronizer.ts +77 -73
- package/src/data-sync/index.ts +8 -8
- package/src/data-sync/types.ts +19 -19
- package/src/data-sync/utils.ts +31 -31
- package/src/errors.ts +47 -47
- package/src/evaluation/EvalResult.ts +35 -35
- package/src/evaluation/Evaluator.ts +26 -26
- package/src/evaluation/IEvalDetail.ts +23 -23
- package/src/evaluation/ReasonKinds.ts +9 -9
- package/src/evaluation/data/IFlag.ts +29 -29
- package/src/evaluation/index.ts +4 -4
- package/src/events/DefaultEventProcessor.ts +83 -83
- package/src/events/DefaultEventQueue.ts +49 -49
- package/src/events/DefaultEventSender.ts +73 -73
- package/src/events/DefaultEventSerializer.ts +11 -11
- package/src/events/EventDispatcher.ts +127 -127
- package/src/events/EventSerializer.ts +4 -4
- package/src/events/IEventProcessor.ts +8 -8
- package/src/events/IEventQueue.ts +16 -16
- package/src/events/IEventSender.ts +13 -13
- package/src/events/NullEventProcessor.ts +15 -15
- package/src/events/event.ts +129 -129
- package/src/events/index.ts +11 -11
- package/src/index.ts +21 -21
- package/src/integrations/TestLogger.ts +24 -24
- package/src/integrations/index.ts +1 -1
- package/src/integrations/test_data/FlagBuilder.ts +59 -59
- package/src/integrations/test_data/TestData.ts +57 -57
- package/src/integrations/test_data/TestDataSynchronizer.ts +49 -49
- package/src/integrations/test_data/index.ts +4 -4
- package/src/logging/BasicLogger.ts +108 -108
- package/src/logging/IBasicLoggerOptions.ts +46 -46
- package/src/logging/ILogger.ts +49 -49
- package/src/logging/LogLevel.ts +8 -8
- package/src/logging/SafeLogger.ts +69 -69
- package/src/logging/format.ts +154 -154
- package/src/logging/index.ts +5 -5
- package/src/options/ClientContext.ts +39 -39
- package/src/options/IClientContext.ts +53 -53
- package/src/options/IOptions.ts +123 -123
- package/src/options/IUser.ts +6 -6
- package/src/options/IValidatedOptions.ts +29 -29
- package/src/options/OptionMessages.ts +35 -35
- package/src/options/UserBuilder.ts +35 -35
- package/src/options/Validators.ts +300 -300
- package/src/options/index.ts +7 -7
- package/src/platform/IInfo.ts +102 -102
- package/src/platform/IPlatform.ts +20 -20
- package/src/platform/IStore.ts +112 -112
- package/src/platform/IWebSocket.ts +22 -22
- package/src/platform/browser/BrowserInfo.ts +24 -24
- package/src/platform/browser/BrowserPlatform.ts +19 -19
- package/src/platform/browser/BrowserRequests.ts +6 -6
- package/src/platform/browser/BrowserWebSocket.ts +147 -142
- package/src/platform/browser/FbClient.ts +65 -65
- package/src/platform/browser/LocalStorageStore.ts +59 -59
- package/src/platform/index.ts +11 -11
- package/src/platform/requests.ts +76 -76
- package/src/store/BaseStore.ts +125 -125
- package/src/store/DataKinds.ts +6 -6
- package/src/store/IDataSourceUpdates.ts +68 -68
- package/src/store/InMemoryStore.ts +36 -36
- package/src/store/index.ts +5 -5
- package/src/store/serialization.ts +52 -52
- package/src/store/store.ts +37 -37
- package/src/utils/Emits.ts +75 -75
- package/src/utils/EventEmitter.ts +128 -128
- package/src/utils/IEventEmitter.ts +14 -14
- package/src/utils/Regex.ts +21 -21
- package/src/utils/ValueConverters.ts +55 -55
- package/src/utils/canonicalizeUri.ts +3 -3
- package/src/utils/debounce.ts +33 -33
- package/src/utils/http.ts +40 -40
- package/src/utils/index.ts +5 -5
- package/src/utils/isNullOrUndefined.ts +2 -2
- package/src/utils/serializeUser.ts +27 -27
- package/src/utils/sleep.ts +5 -5
- package/src/version.ts +1 -1
- package/dist/umd/featbit-js-client-sdk-3.0.11.js.map +0 -1
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { IDataSynchronizer } from "../../data-sync/IDataSynchronizer";
|
|
2
|
-
import { IFlag } from "../../evaluation/data/IFlag";
|
|
3
|
-
import { EventName, ProcessStreamResponse } from "../../data-sync/types";
|
|
4
|
-
import { IDataSourceUpdates } from "../../store/IDataSourceUpdates";
|
|
5
|
-
import { VoidFunction } from "../../utils/VoidFunction";
|
|
6
|
-
import { IDataKind } from "../../IDataKind";
|
|
7
|
-
import { IKeyedStoreItem } from "../../store/store";
|
|
8
|
-
|
|
9
|
-
export default class TestDataSynchronizer implements IDataSynchronizer {
|
|
10
|
-
private readonly flags: IFlag[];
|
|
11
|
-
private readonly userKeyId: string = 'test-user-key-id';
|
|
12
|
-
|
|
13
|
-
constructor(
|
|
14
|
-
private dataSourceUpdates: IDataSourceUpdates,
|
|
15
|
-
initialFlags: IFlag[],
|
|
16
|
-
private readonly onStop: VoidFunction,
|
|
17
|
-
private readonly listeners: Map<EventName, ProcessStreamResponse>
|
|
18
|
-
) {
|
|
19
|
-
// make copies of these objects to decouple them from the originals
|
|
20
|
-
// so updates made to the originals don't affect these internal data.
|
|
21
|
-
this.flags = [...initialFlags];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async start() {
|
|
25
|
-
this.listeners.forEach(({deserializeData, processJson }) => {
|
|
26
|
-
const data = deserializeData(this.flags);
|
|
27
|
-
processJson(this.userKeyId, data);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
identify() {
|
|
32
|
-
// no-op
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
stop() {
|
|
36
|
-
this.onStop();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
close() {
|
|
40
|
-
this.stop();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async upsert(kind: IDataKind, value: IKeyedStoreItem) {
|
|
44
|
-
return new Promise<void>((resolve) => {
|
|
45
|
-
this.dataSourceUpdates.upsert(this.userKeyId, kind, value, () => {
|
|
46
|
-
resolve();
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
}
|
|
1
|
+
import { IDataSynchronizer } from "../../data-sync/IDataSynchronizer";
|
|
2
|
+
import { IFlag } from "../../evaluation/data/IFlag";
|
|
3
|
+
import { EventName, ProcessStreamResponse } from "../../data-sync/types";
|
|
4
|
+
import { IDataSourceUpdates } from "../../store/IDataSourceUpdates";
|
|
5
|
+
import { VoidFunction } from "../../utils/VoidFunction";
|
|
6
|
+
import { IDataKind } from "../../IDataKind";
|
|
7
|
+
import { IKeyedStoreItem } from "../../store/store";
|
|
8
|
+
|
|
9
|
+
export default class TestDataSynchronizer implements IDataSynchronizer {
|
|
10
|
+
private readonly flags: IFlag[];
|
|
11
|
+
private readonly userKeyId: string = 'test-user-key-id';
|
|
12
|
+
|
|
13
|
+
constructor(
|
|
14
|
+
private dataSourceUpdates: IDataSourceUpdates,
|
|
15
|
+
initialFlags: IFlag[],
|
|
16
|
+
private readonly onStop: VoidFunction,
|
|
17
|
+
private readonly listeners: Map<EventName, ProcessStreamResponse>
|
|
18
|
+
) {
|
|
19
|
+
// make copies of these objects to decouple them from the originals
|
|
20
|
+
// so updates made to the originals don't affect these internal data.
|
|
21
|
+
this.flags = [...initialFlags];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async start() {
|
|
25
|
+
this.listeners.forEach(({deserializeData, processJson }) => {
|
|
26
|
+
const data = deserializeData(this.flags);
|
|
27
|
+
processJson(this.userKeyId, data);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async identify(): Promise<void> {
|
|
32
|
+
// no-op
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
stop() {
|
|
36
|
+
this.onStop();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
close() {
|
|
40
|
+
this.stop();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async upsert(kind: IDataKind, value: IKeyedStoreItem) {
|
|
44
|
+
return new Promise<void>((resolve) => {
|
|
45
|
+
this.dataSourceUpdates.upsert(this.userKeyId, kind, value, () => {
|
|
46
|
+
resolve();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
50
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import TestData from "./TestData";
|
|
2
|
-
import { FlagBuilder } from "./FlagBuilder";
|
|
3
|
-
import TestDataSynchronizer from "./TestDataSynchronizer";
|
|
4
|
-
|
|
1
|
+
import TestData from "./TestData";
|
|
2
|
+
import { FlagBuilder } from "./FlagBuilder";
|
|
3
|
+
import TestDataSynchronizer from "./TestDataSynchronizer";
|
|
4
|
+
|
|
5
5
|
export { TestData, FlagBuilder, TestDataSynchronizer };
|
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
import format from './format';
|
|
2
|
-
import { ILogger } from "./ILogger";
|
|
3
|
-
import { IBasicLoggerOptions } from "./IBasicLoggerOptions";
|
|
4
|
-
|
|
5
|
-
const LogPriority = {
|
|
6
|
-
debug: 0,
|
|
7
|
-
info: 1,
|
|
8
|
-
warn: 2,
|
|
9
|
-
error: 3,
|
|
10
|
-
none: 4,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const LevelNames = ['debug', 'info', 'warn', 'error', 'none'];
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* A basic logger which handles filtering by level.
|
|
17
|
-
*
|
|
18
|
-
* With the default options it will write to `console.error`
|
|
19
|
-
* and it will use the formatting provided by `console.error`.
|
|
20
|
-
* If the destination is overwritten, then it will use an included
|
|
21
|
-
* formatter similar to `util.format`.
|
|
22
|
-
*
|
|
23
|
-
* If a formatter is available, then that should be overridden
|
|
24
|
-
* as well for performance.
|
|
25
|
-
*/
|
|
26
|
-
export class BasicLogger implements ILogger {
|
|
27
|
-
private logLevel: number;
|
|
28
|
-
|
|
29
|
-
private name: string;
|
|
30
|
-
|
|
31
|
-
private destination?: (line: string) => void;
|
|
32
|
-
|
|
33
|
-
private formatter?: (...args: any[]) => string;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* This should only be used as a default fallback and not as a convenient
|
|
37
|
-
* solution. In most cases you should construct a new instance with the
|
|
38
|
-
* appropriate options for your specific needs.
|
|
39
|
-
*/
|
|
40
|
-
static get() {
|
|
41
|
-
return new BasicLogger({});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
constructor(options: IBasicLoggerOptions) {
|
|
45
|
-
this.logLevel = LogPriority[options.level ?? 'info'] ?? LogPriority.info;
|
|
46
|
-
this.name = options.name ?? 'FeatBit';
|
|
47
|
-
// eslint-disable-next-line no-console
|
|
48
|
-
this.destination = options.destination;
|
|
49
|
-
this.formatter = options.formatter;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private tryFormat(...args: any[]): string {
|
|
53
|
-
try {
|
|
54
|
-
if (this.formatter) {
|
|
55
|
-
// In case the provided formatter fails.
|
|
56
|
-
return this.formatter?.(...args);
|
|
57
|
-
}
|
|
58
|
-
return format(...args);
|
|
59
|
-
} catch {
|
|
60
|
-
return format(...args);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private tryWrite(msg: string) {
|
|
65
|
-
try {
|
|
66
|
-
this.destination!(msg);
|
|
67
|
-
} catch {
|
|
68
|
-
// eslint-disable-next-line no-console
|
|
69
|
-
console.error(msg);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
private log(level: number, args: any[]) {
|
|
74
|
-
if (level >= this.logLevel) {
|
|
75
|
-
const prefix = `${ LevelNames[level] }: [${ this.name }]`;
|
|
76
|
-
try {
|
|
77
|
-
if (this.destination) {
|
|
78
|
-
this.tryWrite(`${ prefix } ${ this.tryFormat(...args) }`);
|
|
79
|
-
} else {
|
|
80
|
-
// `console.error` has its own formatter.
|
|
81
|
-
// So we don't need to do anything.
|
|
82
|
-
// eslint-disable-next-line no-console
|
|
83
|
-
console.error(...args);
|
|
84
|
-
}
|
|
85
|
-
} catch {
|
|
86
|
-
// If all else fails do not break.
|
|
87
|
-
// eslint-disable-next-line no-console
|
|
88
|
-
console.error(...args);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
error(...args: any[]): void {
|
|
94
|
-
this.log(LogPriority.error, args);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
warn(...args: any[]): void {
|
|
98
|
-
this.log(LogPriority.warn, args);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
info(...args: any[]): void {
|
|
102
|
-
this.log(LogPriority.info, args);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
debug(...args: any[]): void {
|
|
106
|
-
this.log(LogPriority.debug, args);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
1
|
+
import format from './format';
|
|
2
|
+
import { ILogger } from "./ILogger";
|
|
3
|
+
import { IBasicLoggerOptions } from "./IBasicLoggerOptions";
|
|
4
|
+
|
|
5
|
+
const LogPriority = {
|
|
6
|
+
debug: 0,
|
|
7
|
+
info: 1,
|
|
8
|
+
warn: 2,
|
|
9
|
+
error: 3,
|
|
10
|
+
none: 4,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const LevelNames = ['debug', 'info', 'warn', 'error', 'none'];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A basic logger which handles filtering by level.
|
|
17
|
+
*
|
|
18
|
+
* With the default options it will write to `console.error`
|
|
19
|
+
* and it will use the formatting provided by `console.error`.
|
|
20
|
+
* If the destination is overwritten, then it will use an included
|
|
21
|
+
* formatter similar to `util.format`.
|
|
22
|
+
*
|
|
23
|
+
* If a formatter is available, then that should be overridden
|
|
24
|
+
* as well for performance.
|
|
25
|
+
*/
|
|
26
|
+
export class BasicLogger implements ILogger {
|
|
27
|
+
private logLevel: number;
|
|
28
|
+
|
|
29
|
+
private name: string;
|
|
30
|
+
|
|
31
|
+
private destination?: (line: string) => void;
|
|
32
|
+
|
|
33
|
+
private formatter?: (...args: any[]) => string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* This should only be used as a default fallback and not as a convenient
|
|
37
|
+
* solution. In most cases you should construct a new instance with the
|
|
38
|
+
* appropriate options for your specific needs.
|
|
39
|
+
*/
|
|
40
|
+
static get() {
|
|
41
|
+
return new BasicLogger({});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
constructor(options: IBasicLoggerOptions) {
|
|
45
|
+
this.logLevel = LogPriority[options.level ?? 'info'] ?? LogPriority.info;
|
|
46
|
+
this.name = options.name ?? 'FeatBit';
|
|
47
|
+
// eslint-disable-next-line no-console
|
|
48
|
+
this.destination = options.destination;
|
|
49
|
+
this.formatter = options.formatter;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private tryFormat(...args: any[]): string {
|
|
53
|
+
try {
|
|
54
|
+
if (this.formatter) {
|
|
55
|
+
// In case the provided formatter fails.
|
|
56
|
+
return this.formatter?.(...args);
|
|
57
|
+
}
|
|
58
|
+
return format(...args);
|
|
59
|
+
} catch {
|
|
60
|
+
return format(...args);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private tryWrite(msg: string) {
|
|
65
|
+
try {
|
|
66
|
+
this.destination!(msg);
|
|
67
|
+
} catch {
|
|
68
|
+
// eslint-disable-next-line no-console
|
|
69
|
+
console.error(msg);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private log(level: number, args: any[]) {
|
|
74
|
+
if (level >= this.logLevel) {
|
|
75
|
+
const prefix = `${ LevelNames[level] }: [${ this.name }]`;
|
|
76
|
+
try {
|
|
77
|
+
if (this.destination) {
|
|
78
|
+
this.tryWrite(`${ prefix } ${ this.tryFormat(...args) }`);
|
|
79
|
+
} else {
|
|
80
|
+
// `console.error` has its own formatter.
|
|
81
|
+
// So we don't need to do anything.
|
|
82
|
+
// eslint-disable-next-line no-console
|
|
83
|
+
console.error(...args);
|
|
84
|
+
}
|
|
85
|
+
} catch {
|
|
86
|
+
// If all else fails do not break.
|
|
87
|
+
// eslint-disable-next-line no-console
|
|
88
|
+
console.error(...args);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
error(...args: any[]): void {
|
|
94
|
+
this.log(LogPriority.error, args);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
warn(...args: any[]): void {
|
|
98
|
+
this.log(LogPriority.warn, args);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
info(...args: any[]): void {
|
|
102
|
+
this.log(LogPriority.info, args);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
debug(...args: any[]): void {
|
|
106
|
+
this.log(LogPriority.debug, args);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { ILogLevel } from './LogLevel';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Configuration for {@link basicLogger}.
|
|
5
|
-
*/
|
|
6
|
-
export interface IBasicLoggerOptions {
|
|
7
|
-
/**
|
|
8
|
-
* The lowest level of log message to enable.
|
|
9
|
-
*
|
|
10
|
-
* See {@link ILogLevel} for a list of possible levels. Setting a level here causes
|
|
11
|
-
* all lower-importance levels to be disabled: for instance, if you specify
|
|
12
|
-
* `'warn'`, then `'debug'` and `'info'` are disabled.
|
|
13
|
-
*
|
|
14
|
-
* If not specified, the default is `'info'` (meaning that `'debug'` is disabled).
|
|
15
|
-
*/
|
|
16
|
-
level?: ILogLevel;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Name to use for the log entires. The default name is `FeatBit`.
|
|
20
|
-
*/
|
|
21
|
-
name?: string;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* An optional function to use to print each log line.
|
|
25
|
-
*
|
|
26
|
-
* If this is specified, `basicLogger` calls it to write each line of output. The
|
|
27
|
-
* argument is a fully formatted log line, not including a linefeed. The function
|
|
28
|
-
* is only called for log levels that are enabled.
|
|
29
|
-
*
|
|
30
|
-
* If not specified, the default is `console.error`.
|
|
31
|
-
*
|
|
32
|
-
* Setting this property to anything other than a function will cause SDK
|
|
33
|
-
* initialization to fail.
|
|
34
|
-
*/
|
|
35
|
-
destination?: (line: string) => void;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* An optional formatter to use. The formatter should be compatible
|
|
39
|
-
* with browser-style format strings like those used with `util.format`.
|
|
40
|
-
*
|
|
41
|
-
* If not specified, then a default implementation will be used.
|
|
42
|
-
* But using a browser-specific implementation, for instance, would
|
|
43
|
-
* have performance and quality benefits.
|
|
44
|
-
*/
|
|
45
|
-
formatter?: (...args: any[]) => string;
|
|
46
|
-
}
|
|
1
|
+
import { ILogLevel } from './LogLevel';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for {@link basicLogger}.
|
|
5
|
+
*/
|
|
6
|
+
export interface IBasicLoggerOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The lowest level of log message to enable.
|
|
9
|
+
*
|
|
10
|
+
* See {@link ILogLevel} for a list of possible levels. Setting a level here causes
|
|
11
|
+
* all lower-importance levels to be disabled: for instance, if you specify
|
|
12
|
+
* `'warn'`, then `'debug'` and `'info'` are disabled.
|
|
13
|
+
*
|
|
14
|
+
* If not specified, the default is `'info'` (meaning that `'debug'` is disabled).
|
|
15
|
+
*/
|
|
16
|
+
level?: ILogLevel;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Name to use for the log entires. The default name is `FeatBit`.
|
|
20
|
+
*/
|
|
21
|
+
name?: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* An optional function to use to print each log line.
|
|
25
|
+
*
|
|
26
|
+
* If this is specified, `basicLogger` calls it to write each line of output. The
|
|
27
|
+
* argument is a fully formatted log line, not including a linefeed. The function
|
|
28
|
+
* is only called for log levels that are enabled.
|
|
29
|
+
*
|
|
30
|
+
* If not specified, the default is `console.error`.
|
|
31
|
+
*
|
|
32
|
+
* Setting this property to anything other than a function will cause SDK
|
|
33
|
+
* initialization to fail.
|
|
34
|
+
*/
|
|
35
|
+
destination?: (line: string) => void;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* An optional formatter to use. The formatter should be compatible
|
|
39
|
+
* with browser-style format strings like those used with `util.format`.
|
|
40
|
+
*
|
|
41
|
+
* If not specified, then a default implementation will be used.
|
|
42
|
+
* But using a browser-specific implementation, for instance, would
|
|
43
|
+
* have performance and quality benefits.
|
|
44
|
+
*/
|
|
45
|
+
formatter?: (...args: any[]) => string;
|
|
46
|
+
}
|
package/src/logging/ILogger.ts
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The FeatBit client logger interface.
|
|
3
|
-
*
|
|
4
|
-
* The {@link IOptions.logger} property accepts any object that conforms to this
|
|
5
|
-
* interface. The SDK only uses four logging levels: `error`, `warn`, `info`, and
|
|
6
|
-
* `debug`. It will call the corresponding method of the `ILogger` either with a
|
|
7
|
-
* single string argument, or with a format string and variable arguments in the
|
|
8
|
-
* format used by Node's `util.format()`.
|
|
9
|
-
*
|
|
10
|
-
* The [Winston](https://github.com/winstonjs/winston) logging package provides a
|
|
11
|
-
* logger that conforms to this interface, so if you have created a logger with
|
|
12
|
-
* Winston, you can simply put it into the {@link IOptions.logger} property.
|
|
13
|
-
*
|
|
14
|
-
* If you do not provide a logger object, the SDK uses the {@link basicLogger}
|
|
15
|
-
* implementation with a minimum level of `info`.
|
|
16
|
-
*/
|
|
17
|
-
export interface ILogger {
|
|
18
|
-
/**
|
|
19
|
-
* The error logger.
|
|
20
|
-
*
|
|
21
|
-
* @param args
|
|
22
|
-
* A sequence of any JavaScript values.
|
|
23
|
-
*/
|
|
24
|
-
error(...args: any[]): void;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* The warning logger.
|
|
28
|
-
*
|
|
29
|
-
* @param args
|
|
30
|
-
* A sequence of any JavaScript values.
|
|
31
|
-
*/
|
|
32
|
-
warn(...args: any[]): void;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* The info logger.
|
|
36
|
-
*
|
|
37
|
-
* @param args
|
|
38
|
-
* A sequence of any JavaScript values.
|
|
39
|
-
*/
|
|
40
|
-
info(...args: any[]): void;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The debug logger.
|
|
44
|
-
*
|
|
45
|
-
* @param args
|
|
46
|
-
* A sequence of any JavaScript values.
|
|
47
|
-
*/
|
|
48
|
-
debug(...args: any[]): void;
|
|
49
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* The FeatBit client logger interface.
|
|
3
|
+
*
|
|
4
|
+
* The {@link IOptions.logger} property accepts any object that conforms to this
|
|
5
|
+
* interface. The SDK only uses four logging levels: `error`, `warn`, `info`, and
|
|
6
|
+
* `debug`. It will call the corresponding method of the `ILogger` either with a
|
|
7
|
+
* single string argument, or with a format string and variable arguments in the
|
|
8
|
+
* format used by Node's `util.format()`.
|
|
9
|
+
*
|
|
10
|
+
* The [Winston](https://github.com/winstonjs/winston) logging package provides a
|
|
11
|
+
* logger that conforms to this interface, so if you have created a logger with
|
|
12
|
+
* Winston, you can simply put it into the {@link IOptions.logger} property.
|
|
13
|
+
*
|
|
14
|
+
* If you do not provide a logger object, the SDK uses the {@link basicLogger}
|
|
15
|
+
* implementation with a minimum level of `info`.
|
|
16
|
+
*/
|
|
17
|
+
export interface ILogger {
|
|
18
|
+
/**
|
|
19
|
+
* The error logger.
|
|
20
|
+
*
|
|
21
|
+
* @param args
|
|
22
|
+
* A sequence of any JavaScript values.
|
|
23
|
+
*/
|
|
24
|
+
error(...args: any[]): void;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The warning logger.
|
|
28
|
+
*
|
|
29
|
+
* @param args
|
|
30
|
+
* A sequence of any JavaScript values.
|
|
31
|
+
*/
|
|
32
|
+
warn(...args: any[]): void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The info logger.
|
|
36
|
+
*
|
|
37
|
+
* @param args
|
|
38
|
+
* A sequence of any JavaScript values.
|
|
39
|
+
*/
|
|
40
|
+
info(...args: any[]): void;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The debug logger.
|
|
44
|
+
*
|
|
45
|
+
* @param args
|
|
46
|
+
* A sequence of any JavaScript values.
|
|
47
|
+
*/
|
|
48
|
+
debug(...args: any[]): void;
|
|
49
|
+
}
|
package/src/logging/LogLevel.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Logging levels that can be used with {@link basicLogger}.
|
|
3
|
-
*
|
|
4
|
-
* Set {@link BasicLoggerOptions.level} to one of these values to control what levels
|
|
5
|
-
* of log messages are enabled. Going from lowest importance (and most verbose)
|
|
6
|
-
* to most importance, the levels are `'debug'`, `'info'`, `'warn'`, and `'error'`.
|
|
7
|
-
* You can also specify `'none'` instead to disable all logging.
|
|
8
|
-
*/
|
|
1
|
+
/**
|
|
2
|
+
* Logging levels that can be used with {@link basicLogger}.
|
|
3
|
+
*
|
|
4
|
+
* Set {@link BasicLoggerOptions.level} to one of these values to control what levels
|
|
5
|
+
* of log messages are enabled. Going from lowest importance (and most verbose)
|
|
6
|
+
* to most importance, the levels are `'debug'`, `'info'`, `'warn'`, and `'error'`.
|
|
7
|
+
* You can also specify `'none'` instead to disable all logging.
|
|
8
|
+
*/
|
|
9
9
|
export type ILogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
|