@webex/plugin-logger 3.12.0-next.6 → 3.12.0-next.61
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/.repo-context.json +389 -0
- package/.sdd/manifest.json +334 -0
- package/AGENTS.md +175 -0
- package/dist/logger.js +37 -4
- package/dist/logger.js.map +1 -1
- package/docs/adr/0001-retain-product-readme.md +76 -0
- package/docs/adr/index.md +18 -0
- package/docs/architecture.md +252 -0
- package/docs/getting-started.md +88 -0
- package/docs/index.md +42 -0
- package/docs/specs/README.md +65 -0
- package/package.json +10 -10
- package/schemas/repo-context.schema.json +796 -0
- package/src/docs/README.md +320 -0
- package/src/logger.js +36 -0
- package/test/unit/spec/logger.js +318 -54
package/test/unit/spec/logger.js
CHANGED
|
@@ -128,6 +128,69 @@ describe('plugin-logger', () => {
|
|
|
128
128
|
assert.equal(webex.logger.buffer.buffer[1][3], 3);
|
|
129
129
|
});
|
|
130
130
|
|
|
131
|
+
it('adjusts lastSubmitted when buffer overflows in single buffer mode', () => {
|
|
132
|
+
webex.config.logger.historyLength = 3;
|
|
133
|
+
|
|
134
|
+
webex.logger.log('a');
|
|
135
|
+
webex.logger.log('b');
|
|
136
|
+
|
|
137
|
+
// simulate a successful upload
|
|
138
|
+
webex.logger.formatLogs({diff: true});
|
|
139
|
+
webex.logger.updateLastSubmittedIndex();
|
|
140
|
+
assert.equal(webex.logger.buffer.lastSubmitted, 2);
|
|
141
|
+
|
|
142
|
+
// add more logs to trigger overflow
|
|
143
|
+
webex.logger.log('c');
|
|
144
|
+
webex.logger.log('d');
|
|
145
|
+
|
|
146
|
+
// buffer overflowed by 1, so lastSubmitted should be decremented by 1
|
|
147
|
+
assert.equal(webex.logger.buffer.lastSubmitted, 1);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('clamps lastSubmitted to 0 when buffer overflow exceeds lastSubmitted in single buffer mode', () => {
|
|
151
|
+
webex.config.logger.historyLength = 2;
|
|
152
|
+
|
|
153
|
+
webex.logger.log('a');
|
|
154
|
+
|
|
155
|
+
// simulate a successful upload after just 1 log
|
|
156
|
+
webex.logger.formatLogs({diff: true});
|
|
157
|
+
webex.logger.updateLastSubmittedIndex();
|
|
158
|
+
assert.equal(webex.logger.buffer.lastSubmitted, 1);
|
|
159
|
+
|
|
160
|
+
// add enough logs to overflow past the lastSubmitted value
|
|
161
|
+
webex.logger.log('b');
|
|
162
|
+
webex.logger.log('c');
|
|
163
|
+
webex.logger.log('d');
|
|
164
|
+
|
|
165
|
+
assert.equal(webex.logger.buffer.lastSubmitted, 0);
|
|
166
|
+
assert.lengthOf(webex.logger.buffer.buffer, 2);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('adjusts lastSubmitted when buffer overflows in separate buffer mode', () => {
|
|
170
|
+
webex.config.logger.separateLogBuffers = true;
|
|
171
|
+
webex.config.logger.clientName = 'someclient';
|
|
172
|
+
webex.config.logger.historyLength = 3;
|
|
173
|
+
|
|
174
|
+
webex.logger.log('sdk1');
|
|
175
|
+
webex.logger.log('sdk2');
|
|
176
|
+
webex.logger.client_log('client1');
|
|
177
|
+
webex.logger.client_log('client2');
|
|
178
|
+
|
|
179
|
+
webex.logger.formatLogs({diff: true});
|
|
180
|
+
webex.logger.updateLastSubmittedIndex();
|
|
181
|
+
assert.equal(webex.logger.sdkBuffer.lastSubmitted, 2);
|
|
182
|
+
assert.equal(webex.logger.clientBuffer.lastSubmitted, 2);
|
|
183
|
+
|
|
184
|
+
// overflow both buffers by 1
|
|
185
|
+
webex.logger.log('sdk3');
|
|
186
|
+
webex.logger.log('sdk4');
|
|
187
|
+
webex.logger.client_log('client3');
|
|
188
|
+
webex.logger.client_log('client4');
|
|
189
|
+
|
|
190
|
+
assert.equal(webex.logger.sdkBuffer.lastSubmitted, 1);
|
|
191
|
+
assert.equal(webex.logger.clientBuffer.lastSubmitted, 1);
|
|
192
|
+
});
|
|
193
|
+
|
|
131
194
|
it('prevents the client and sdk buffer from overflowing', () => {
|
|
132
195
|
webex.config.logger.historyLength = 2;
|
|
133
196
|
webex.config.logger.separateLogBuffers = true;
|
|
@@ -196,8 +259,8 @@ describe('plugin-logger', () => {
|
|
|
196
259
|
test: 'object',
|
|
197
260
|
nested: {
|
|
198
261
|
test2: 'object2',
|
|
199
|
-
}
|
|
200
|
-
}
|
|
262
|
+
},
|
|
263
|
+
};
|
|
201
264
|
|
|
202
265
|
webex.logger.log('foo', 'bar', obj);
|
|
203
266
|
assert.lengthOf(webex.logger.buffer.buffer, 1);
|
|
@@ -205,7 +268,10 @@ describe('plugin-logger', () => {
|
|
|
205
268
|
assert.deepEqual(webex.logger.buffer.buffer[0][2], 'wx-js-sdk');
|
|
206
269
|
assert.deepEqual(webex.logger.buffer.buffer[0][3], 'foo');
|
|
207
270
|
assert.deepEqual(webex.logger.buffer.buffer[0][4], 'bar');
|
|
208
|
-
assert.deepEqual(
|
|
271
|
+
assert.deepEqual(
|
|
272
|
+
webex.logger.buffer.buffer[0][5],
|
|
273
|
+
'{"headers":{"trackingid":"123"},"test":"object","nested":{"test2":"object2"}}'
|
|
274
|
+
);
|
|
209
275
|
});
|
|
210
276
|
|
|
211
277
|
it('formats objects as strings passed to the logger for readability not [Object object] w/ circular reference', async () => {
|
|
@@ -218,8 +284,8 @@ describe('plugin-logger', () => {
|
|
|
218
284
|
test: 'object',
|
|
219
285
|
nested: {
|
|
220
286
|
test2: 'object2',
|
|
221
|
-
}
|
|
222
|
-
}
|
|
287
|
+
},
|
|
288
|
+
};
|
|
223
289
|
|
|
224
290
|
obj.selfReference = obj;
|
|
225
291
|
|
|
@@ -229,19 +295,21 @@ describe('plugin-logger', () => {
|
|
|
229
295
|
assert.deepEqual(webex.logger.buffer.buffer[0][2], 'wx-js-sdk');
|
|
230
296
|
assert.deepEqual(webex.logger.buffer.buffer[0][3], 'foo');
|
|
231
297
|
assert.deepEqual(webex.logger.buffer.buffer[0][4], 'bar');
|
|
232
|
-
assert.deepEqual(
|
|
298
|
+
assert.deepEqual(
|
|
299
|
+
webex.logger.buffer.buffer[0][5],
|
|
300
|
+
'{"headers":{"trackingid":"123"},"test":"object","nested":{"test2":"object2"}}'
|
|
301
|
+
);
|
|
233
302
|
});
|
|
234
303
|
|
|
235
304
|
it('formats Errors correctly', async () => {
|
|
236
305
|
webex.config.logger.level = 'trace';
|
|
237
|
-
const err = new Error('fake error for testing')
|
|
306
|
+
const err = new Error('fake error for testing');
|
|
238
307
|
|
|
239
308
|
webex.logger.log('I got this error:', err);
|
|
240
309
|
assert.lengthOf(webex.logger.buffer.buffer, 1);
|
|
241
310
|
assert.deepEqual(webex.logger.buffer.buffer[0][2], 'wx-js-sdk');
|
|
242
311
|
assert.deepEqual(webex.logger.buffer.buffer[0][3], 'I got this error:');
|
|
243
312
|
assert.deepEqual(webex.logger.buffer.buffer[0][4], 'Error: fake error for testing');
|
|
244
|
-
|
|
245
313
|
});
|
|
246
314
|
});
|
|
247
315
|
|
|
@@ -649,12 +717,16 @@ describe('plugin-logger', () => {
|
|
|
649
717
|
},
|
|
650
718
|
});
|
|
651
719
|
|
|
652
|
-
if(inBrowser()) {
|
|
653
|
-
assert.calledWith(
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
720
|
+
if (inBrowser()) {
|
|
721
|
+
assert.calledWith(
|
|
722
|
+
console[impl(level)],
|
|
723
|
+
'wx-js-sdk',
|
|
724
|
+
JSON.stringify({
|
|
725
|
+
headers: {
|
|
726
|
+
trackingid: '123',
|
|
727
|
+
},
|
|
728
|
+
})
|
|
729
|
+
);
|
|
658
730
|
} else {
|
|
659
731
|
assert.calledWith(console[impl(level)], 'wx-js-sdk', {
|
|
660
732
|
headers: {
|
|
@@ -676,24 +748,23 @@ describe('plugin-logger', () => {
|
|
|
676
748
|
|
|
677
749
|
// Assert auth was filtered
|
|
678
750
|
|
|
679
|
-
if(inBrowser()) {
|
|
680
|
-
assert.calledWith(console.log,
|
|
751
|
+
if (inBrowser()) {
|
|
752
|
+
assert.calledWith(console.log, 'wx-js-sdk', JSON.stringify({Key: 'myKey'}));
|
|
681
753
|
} else {
|
|
682
|
-
assert.calledWith(console.log,
|
|
754
|
+
assert.calledWith(console.log, 'wx-js-sdk', {Key: 'myKey'});
|
|
683
755
|
}
|
|
684
|
-
|
|
756
|
+
webex.logger.log({
|
|
685
757
|
authorization: 'XXXXXXX',
|
|
686
758
|
Key: 'myKey',
|
|
687
759
|
});
|
|
688
|
-
9
|
|
689
|
-
|
|
690
|
-
if(inBrowser()) {
|
|
691
|
-
assert.calledWith(console.log, "wx-js-sdk", JSON.stringify({Key: 'myKey'}));
|
|
760
|
+
9;
|
|
692
761
|
|
|
762
|
+
if (inBrowser()) {
|
|
763
|
+
assert.calledWith(console.log, 'wx-js-sdk', JSON.stringify({Key: 'myKey'}));
|
|
693
764
|
} else {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
765
|
+
assert.calledWith(console.log, 'wx-js-sdk', {Key: 'myKey'});
|
|
766
|
+
}
|
|
767
|
+
});
|
|
697
768
|
|
|
698
769
|
it('redact emails', () => {
|
|
699
770
|
webex.config.logger.level = 'trace';
|
|
@@ -708,21 +779,42 @@ describe('plugin-logger', () => {
|
|
|
708
779
|
it('redact MTID', () => {
|
|
709
780
|
webex.config.logger.level = 'trace';
|
|
710
781
|
|
|
711
|
-
const destination =
|
|
782
|
+
const destination =
|
|
783
|
+
'https://example.com/example/j.php?MTID=m678957bc1eff989c2176b43ead9d46b5';
|
|
712
784
|
|
|
713
|
-
webex.logger.log(
|
|
714
|
-
|
|
785
|
+
webex.logger.log(`Info Unable to fetch meeting info for ${destination}.`);
|
|
786
|
+
assert.calledWith(
|
|
787
|
+
console.log,
|
|
788
|
+
'wx-js-sdk',
|
|
789
|
+
'Info Unable to fetch meeting info for https://example.com/example/j.php?MTID=[REDACTED]'
|
|
715
790
|
);
|
|
716
|
-
assert.calledWith(console.log, 'wx-js-sdk', 'Info Unable to fetch meeting info for https://example.com/example/j.php?MTID=[REDACTED]');
|
|
717
791
|
|
|
718
|
-
webex.logger.log(
|
|
719
|
-
|
|
792
|
+
webex.logger.log(
|
|
793
|
+
'https://example.com/example/j.php?MTID=m678957bc1eff989c2176b43ead9d46b5&abcdefg'
|
|
794
|
+
);
|
|
795
|
+
assert.calledWith(
|
|
796
|
+
console.log,
|
|
797
|
+
'wx-js-sdk',
|
|
798
|
+
'https://example.com/example/j.php?MTID=[REDACTED]&abcdefg'
|
|
799
|
+
);
|
|
720
800
|
|
|
721
|
-
webex.logger.log(
|
|
722
|
-
|
|
801
|
+
webex.logger.log(
|
|
802
|
+
'https://example.com/example/j.php?MTID=m678957bc1eff989c2176b43ead9d46b5$abcdefg'
|
|
803
|
+
);
|
|
804
|
+
assert.calledWith(
|
|
805
|
+
console.log,
|
|
806
|
+
'wx-js-sdk',
|
|
807
|
+
'https://example.com/example/j.php?MTID=[REDACTED]$abcdefg'
|
|
808
|
+
);
|
|
723
809
|
|
|
724
|
-
webex.logger.log(
|
|
725
|
-
|
|
810
|
+
webex.logger.log(
|
|
811
|
+
'https://example.com/example/j.php?MTID=m678957bc1eff989c2176b43ead9d46b5#abcdefg'
|
|
812
|
+
);
|
|
813
|
+
assert.calledWith(
|
|
814
|
+
console.log,
|
|
815
|
+
'wx-js-sdk',
|
|
816
|
+
'https://example.com/example/j.php?MTID=[REDACTED]#abcdefg'
|
|
817
|
+
);
|
|
726
818
|
});
|
|
727
819
|
|
|
728
820
|
nodeOnly(it)('handle circular references', () => {
|
|
@@ -744,17 +836,15 @@ describe('plugin-logger', () => {
|
|
|
744
836
|
Key: 'myKey',
|
|
745
837
|
};
|
|
746
838
|
|
|
747
|
-
// Has self reference which is bad
|
|
839
|
+
// Has self reference which is bad
|
|
748
840
|
expected.selfReference = expected;
|
|
749
841
|
|
|
750
|
-
if(inBrowser()) {
|
|
751
|
-
assert.calledWith(console.log,
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
}
|
|
757
|
-
});
|
|
842
|
+
if (inBrowser()) {
|
|
843
|
+
assert.calledWith(console.log, 'wx-js-sdk', JSON.stringify(expected));
|
|
844
|
+
} else {
|
|
845
|
+
assert.calledWith(console.log, 'wx-js-sdk', expected);
|
|
846
|
+
}
|
|
847
|
+
});
|
|
758
848
|
|
|
759
849
|
nodeOnly(it)('handle circular references in complex objects', () => {
|
|
760
850
|
webex.config.logger.level = 'trace';
|
|
@@ -802,18 +892,15 @@ describe('plugin-logger', () => {
|
|
|
802
892
|
circularObjectRef: object,
|
|
803
893
|
circularFunctionRef: func,
|
|
804
894
|
},
|
|
805
|
-
}
|
|
806
|
-
|
|
895
|
+
};
|
|
807
896
|
|
|
808
|
-
if(inBrowser()) {
|
|
809
|
-
assert.calledWith(console.log,
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
}
|
|
815
|
-
});
|
|
897
|
+
if (inBrowser()) {
|
|
898
|
+
assert.calledWith(console.log, 'wx-js-sdk', JSON.stringify(res));
|
|
899
|
+
} else {
|
|
900
|
+
assert.calledWith(console.log, 'wx-js-sdk', res);
|
|
901
|
+
}
|
|
816
902
|
});
|
|
903
|
+
});
|
|
817
904
|
|
|
818
905
|
describe('#formatLogs()', () => {
|
|
819
906
|
function sendRandomLog(log) {
|
|
@@ -1265,4 +1352,181 @@ describe('plugin-logger', () => {
|
|
|
1265
1352
|
assert.lengthOf(webex.logger.buffer.buffer, 5);
|
|
1266
1353
|
});
|
|
1267
1354
|
});
|
|
1355
|
+
|
|
1356
|
+
describe('#updateLastSubmittedIndex()', () => {
|
|
1357
|
+
let clock;
|
|
1358
|
+
|
|
1359
|
+
beforeEach(() => {
|
|
1360
|
+
clock = sinon.useFakeTimers();
|
|
1361
|
+
});
|
|
1362
|
+
|
|
1363
|
+
afterEach(() => {
|
|
1364
|
+
clock.restore();
|
|
1365
|
+
});
|
|
1366
|
+
|
|
1367
|
+
it('updates lastSubmitted to the current nextIndex in single buffer mode', () => {
|
|
1368
|
+
webex.config.logger.separateLogBuffers = false;
|
|
1369
|
+
|
|
1370
|
+
webex.logger.log('a');
|
|
1371
|
+
clock.tick(1000);
|
|
1372
|
+
webex.logger.log('b');
|
|
1373
|
+
clock.tick(1000);
|
|
1374
|
+
|
|
1375
|
+
// advance nextIndex by consuming a diff
|
|
1376
|
+
webex.logger.formatLogs({diff: true});
|
|
1377
|
+
const nextIndexAfterDiff = webex.logger.buffer.nextIndex;
|
|
1378
|
+
|
|
1379
|
+
assert.equal(webex.logger.buffer.lastSubmitted, 0);
|
|
1380
|
+
|
|
1381
|
+
webex.logger.updateLastSubmittedIndex();
|
|
1382
|
+
|
|
1383
|
+
assert.equal(webex.logger.buffer.lastSubmitted, nextIndexAfterDiff);
|
|
1384
|
+
});
|
|
1385
|
+
|
|
1386
|
+
it('updates lastSubmitted to the current nextIndex in separate buffer mode', () => {
|
|
1387
|
+
webex.config.logger.separateLogBuffers = true;
|
|
1388
|
+
webex.config.logger.clientName = 'someclient';
|
|
1389
|
+
|
|
1390
|
+
webex.logger.log('sdk1');
|
|
1391
|
+
clock.tick(1000);
|
|
1392
|
+
webex.logger.client_log('client1');
|
|
1393
|
+
clock.tick(1000);
|
|
1394
|
+
|
|
1395
|
+
webex.logger.formatLogs({diff: true});
|
|
1396
|
+
const sdkNextIndex = webex.logger.sdkBuffer.nextIndex;
|
|
1397
|
+
const clientNextIndex = webex.logger.clientBuffer.nextIndex;
|
|
1398
|
+
|
|
1399
|
+
assert.equal(webex.logger.sdkBuffer.lastSubmitted, 0);
|
|
1400
|
+
assert.equal(webex.logger.clientBuffer.lastSubmitted, 0);
|
|
1401
|
+
|
|
1402
|
+
webex.logger.updateLastSubmittedIndex();
|
|
1403
|
+
|
|
1404
|
+
assert.equal(webex.logger.sdkBuffer.lastSubmitted, sdkNextIndex);
|
|
1405
|
+
assert.equal(webex.logger.clientBuffer.lastSubmitted, clientNextIndex);
|
|
1406
|
+
});
|
|
1407
|
+
|
|
1408
|
+
it('stores lastSubmitted as 0 when no diff has been consumed yet in single buffer mode', () => {
|
|
1409
|
+
webex.config.logger.separateLogBuffers = false;
|
|
1410
|
+
|
|
1411
|
+
webex.logger.log('a');
|
|
1412
|
+
webex.logger.updateLastSubmittedIndex();
|
|
1413
|
+
|
|
1414
|
+
// nextIndex is still 0 because no diff was consumed
|
|
1415
|
+
assert.equal(webex.logger.buffer.lastSubmitted, webex.logger.buffer.nextIndex);
|
|
1416
|
+
});
|
|
1417
|
+
});
|
|
1418
|
+
|
|
1419
|
+
describe('#resetBufferToLastSuccessfulUpload()', () => {
|
|
1420
|
+
let clock;
|
|
1421
|
+
|
|
1422
|
+
beforeEach(() => {
|
|
1423
|
+
clock = sinon.useFakeTimers();
|
|
1424
|
+
});
|
|
1425
|
+
|
|
1426
|
+
afterEach(() => {
|
|
1427
|
+
clock.restore();
|
|
1428
|
+
});
|
|
1429
|
+
|
|
1430
|
+
it('resets nextIndex to lastSubmitted in single buffer mode', () => {
|
|
1431
|
+
webex.config.logger.separateLogBuffers = false;
|
|
1432
|
+
|
|
1433
|
+
webex.logger.log('a');
|
|
1434
|
+
clock.tick(1000);
|
|
1435
|
+
webex.logger.log('b');
|
|
1436
|
+
clock.tick(1000);
|
|
1437
|
+
|
|
1438
|
+
// simulate a successful upload: consume diff then mark as submitted
|
|
1439
|
+
webex.logger.formatLogs({diff: true});
|
|
1440
|
+
webex.logger.updateLastSubmittedIndex();
|
|
1441
|
+
const submittedIndex = webex.logger.buffer.lastSubmitted;
|
|
1442
|
+
|
|
1443
|
+
// log more entries (simulating logs added after the upload)
|
|
1444
|
+
webex.logger.log('c');
|
|
1445
|
+
clock.tick(1000);
|
|
1446
|
+
webex.logger.formatLogs({diff: true});
|
|
1447
|
+
assert.isAbove(webex.logger.buffer.nextIndex, submittedIndex);
|
|
1448
|
+
|
|
1449
|
+
// simulate upload failure — reset so the next diff re-includes logs since last success
|
|
1450
|
+
webex.logger.resetBufferToLastSuccessfulUpload();
|
|
1451
|
+
|
|
1452
|
+
assert.equal(webex.logger.buffer.nextIndex, submittedIndex);
|
|
1453
|
+
});
|
|
1454
|
+
|
|
1455
|
+
it('resets nextIndex to lastSubmitted in separate buffer mode', () => {
|
|
1456
|
+
webex.config.logger.separateLogBuffers = true;
|
|
1457
|
+
webex.config.logger.clientName = 'someclient';
|
|
1458
|
+
|
|
1459
|
+
webex.logger.log('sdk1');
|
|
1460
|
+
clock.tick(1000);
|
|
1461
|
+
webex.logger.client_log('client1');
|
|
1462
|
+
clock.tick(1000);
|
|
1463
|
+
|
|
1464
|
+
webex.logger.formatLogs({diff: true});
|
|
1465
|
+
webex.logger.updateLastSubmittedIndex();
|
|
1466
|
+
const submittedSdk = webex.logger.sdkBuffer.lastSubmitted;
|
|
1467
|
+
const submittedClient = webex.logger.clientBuffer.lastSubmitted;
|
|
1468
|
+
|
|
1469
|
+
webex.logger.log('sdk2');
|
|
1470
|
+
clock.tick(1000);
|
|
1471
|
+
webex.logger.client_log('client2');
|
|
1472
|
+
clock.tick(1000);
|
|
1473
|
+
webex.logger.formatLogs({diff: true});
|
|
1474
|
+
|
|
1475
|
+
assert.isAbove(webex.logger.sdkBuffer.nextIndex, submittedSdk);
|
|
1476
|
+
assert.isAbove(webex.logger.clientBuffer.nextIndex, submittedClient);
|
|
1477
|
+
|
|
1478
|
+
webex.logger.resetBufferToLastSuccessfulUpload();
|
|
1479
|
+
|
|
1480
|
+
assert.equal(webex.logger.sdkBuffer.nextIndex, submittedSdk);
|
|
1481
|
+
assert.equal(webex.logger.clientBuffer.nextIndex, submittedClient);
|
|
1482
|
+
});
|
|
1483
|
+
|
|
1484
|
+
it('causes the next diff to re-include logs since the last successful upload', () => {
|
|
1485
|
+
webex.config.logger.separateLogBuffers = false;
|
|
1486
|
+
|
|
1487
|
+
webex.logger.log('a');
|
|
1488
|
+
clock.tick(1000);
|
|
1489
|
+
webex.logger.log('b');
|
|
1490
|
+
clock.tick(1000);
|
|
1491
|
+
|
|
1492
|
+
// first successful upload
|
|
1493
|
+
const diff1 = webex.logger.formatLogs({diff: true});
|
|
1494
|
+
|
|
1495
|
+
assert.deepEqual(diff1.split('\n'), [
|
|
1496
|
+
',1970-01-01T00:00:00.000Z,wx-js-sdk,a',
|
|
1497
|
+
',1970-01-01T00:00:01.000Z,wx-js-sdk,b',
|
|
1498
|
+
]);
|
|
1499
|
+
webex.logger.updateLastSubmittedIndex();
|
|
1500
|
+
|
|
1501
|
+
// new logs arrive
|
|
1502
|
+
webex.logger.log('c');
|
|
1503
|
+
clock.tick(1000);
|
|
1504
|
+
|
|
1505
|
+
// consume the diff (upload attempt that fails)
|
|
1506
|
+
const diff2 = webex.logger.formatLogs({diff: true});
|
|
1507
|
+
|
|
1508
|
+
assert.deepEqual(diff2.split('\n'), [',1970-01-01T00:00:02.000Z,wx-js-sdk,c']);
|
|
1509
|
+
|
|
1510
|
+
// upload failed — roll back
|
|
1511
|
+
webex.logger.resetBufferToLastSuccessfulUpload();
|
|
1512
|
+
|
|
1513
|
+
// retry: should get 'c' again
|
|
1514
|
+
const diff3 = webex.logger.formatLogs({diff: true});
|
|
1515
|
+
|
|
1516
|
+
assert.deepEqual(diff3.split('\n'), [',1970-01-01T00:00:02.000Z,wx-js-sdk,c']);
|
|
1517
|
+
});
|
|
1518
|
+
|
|
1519
|
+
it('resets nextIndex to 0 when updateLastSubmittedIndex was never called', () => {
|
|
1520
|
+
webex.config.logger.separateLogBuffers = false;
|
|
1521
|
+
|
|
1522
|
+
webex.logger.log('a');
|
|
1523
|
+
webex.logger.formatLogs({diff: true});
|
|
1524
|
+
assert.equal(webex.logger.buffer.nextIndex, 1);
|
|
1525
|
+
|
|
1526
|
+
// lastSubmitted defaults to 0 before any call to updateLastSubmittedIndex
|
|
1527
|
+
webex.logger.resetBufferToLastSuccessfulUpload();
|
|
1528
|
+
|
|
1529
|
+
assert.equal(webex.logger.buffer.nextIndex, 0);
|
|
1530
|
+
});
|
|
1531
|
+
});
|
|
1268
1532
|
});
|