@mimik/sumologic-winston-logger 2.1.13 → 2.2.0

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.
@@ -1,600 +0,0 @@
1
- import './testEnv.js';
2
- import { KinesisClient, PutRecordsCommand } from '@aws-sdk/client-kinesis';
3
- import {
4
- NOT_FOUND_ERROR,
5
- OK_EXIT,
6
- OK_RESPONSE,
7
- SPLAT,
8
- SYSTEM_ERROR,
9
- TEAPOT_ERROR,
10
- TEST_FLUSH_TIMEOUT,
11
- TEST_START_TIMEOUT,
12
- UNAUTHORIZED_ERROR,
13
- } from '../lib/common.js';
14
- import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3';
15
- import { after, afterEach, before, beforeEach, describe, it } from 'mocha';
16
- import Sumo from '../lib/sumologicTransport.js';
17
- import express from 'express';
18
- import { getCorrelationId } from '@mimik/request-helper';
19
- import logger from '../index.js';
20
- import { mockClient } from 'aws-sdk-client-mock';
21
- import process from 'node:process';
22
- import { setTimeout } from 'node:timers';
23
- import { should } from 'chai';
24
- import { stub } from 'sinon';
25
-
26
- import { checkConfig, checkMode } from '../configuration/config.js';
27
- import { parseStack } from '../lib/stackLib.js';
28
-
29
- const s3Mock = mockClient(S3Client);
30
- const kinesisMock = mockClient(KinesisClient);
31
-
32
- s3Mock.on(PutObjectCommand).resolves({});
33
- kinesisMock.on(PutRecordsCommand).resolves({});
34
-
35
- const correlationId = getCorrelationId('--sumologic-winston-logger-test--');
36
-
37
- const TEST_DELAY = 200;
38
-
39
- should();
40
-
41
- describe('sumologic-winston-logger Unit Tests', function LoggerTests() {
42
- this.timeout(TEST_START_TIMEOUT);
43
- it('Can log a debug message without a correlationId and info', () => {
44
- logger.debug('this is a debug statement');
45
- });
46
- it('Can log an error message without a correlationId and info', () => {
47
- logger.error('this is an error statement');
48
- });
49
- it('Can log an error message without a correlationId', () => {
50
- logger.error('this is an error statement', { error: new Error('this is an error') });
51
- });
52
- it('Can log a warning message with a correlationId', () => {
53
- logger.warn('this is a warning statement', { meta: 'data' }, correlationId);
54
- });
55
- it('Can log an info message', () => {
56
- logger.info('this is an info statement', { meta: 'data' });
57
- });
58
- it('Can log a verbose message', () => {
59
- logger.verbose('this is a verbose statement', 'an extra string', { meta: 'data' });
60
- });
61
- it('Can log a debug message with no object and no correlationId', () => {
62
- logger.debug('this is a debug statement');
63
- });
64
- it('can flush logs', () => {
65
- logger.flush();
66
- });
67
- it('Can flush and exit', (done) => {
68
- logger.debug('this is a debug statement');
69
- stub(process, 'exit');
70
- logger.flushAndExit(OK_EXIT);
71
- done();
72
- });
73
- after(done => setTimeout(() => { // adding a delay to make sure that the flush is done
74
- clearTimeout(logger.safetyTimer);
75
- process.exit.restore();
76
- done();
77
- }, TEST_FLUSH_TIMEOUT));
78
- });
79
-
80
- describe('Sumologic transport', function SumoTests() {
81
- this.timeout(TEST_START_TIMEOUT);
82
- let server;
83
- let port;
84
- let sumo;
85
-
86
- before((done) => {
87
- const app = express();
88
- app.post('/logs/ok', (_req, res) => res.sendStatus(OK_RESPONSE));
89
- app.post('/logs/401', (_req, res) => res.sendStatus(UNAUTHORIZED_ERROR));
90
- app.post('/logs/404', (_req, res) => res.sendStatus(NOT_FOUND_ERROR));
91
- app.post('/logs/500', (_req, res) => res.sendStatus(SYSTEM_ERROR));
92
- app.post('/logs/bad', (_req, res) => res.sendStatus(TEAPOT_ERROR));
93
- server = app.listen(0, () => {
94
- ({ port } = server.address());
95
- sumo = new Sumo({
96
- endpoint: `http://localhost:${port}/logs/`,
97
- code: 'ok',
98
- serverType: 'mTest',
99
- serverId: 'testId',
100
- level: 'info',
101
- });
102
- done();
103
- });
104
- });
105
-
106
- after(done => server.close(done));
107
-
108
- beforeEach(() => {
109
- sumo.removeAllListeners();
110
- sumo.code = 'ok';
111
- sumo.endpoint = `http://localhost:${port}/logs/`;
112
- });
113
-
114
- it('sends logs successfully', (done) => {
115
- sumo.once('logged', () => done());
116
- sumo.log({ level: 'info', message: 'test success' });
117
- });
118
-
119
- it('handles 401 unauthorized error', (done) => {
120
- sumo.code = '401';
121
- sumo.once('warn', (data) => {
122
- data.error.statusCode.should.equal(UNAUTHORIZED_ERROR);
123
- data.error.message.should.include('invalid');
124
- data.should.have.property('code');
125
- done();
126
- });
127
- sumo.log({ level: 'info', message: 'test 401' });
128
- });
129
-
130
- it('handles 404 not found error', (done) => {
131
- sumo.code = '404';
132
- sumo.once('warn', (data) => {
133
- data.error.statusCode.should.equal(NOT_FOUND_ERROR);
134
- data.error.message.should.include('invalid');
135
- done();
136
- });
137
- sumo.log({ level: 'info', message: 'test 404' });
138
- });
139
-
140
- it('handles 500 server error', (done) => {
141
- sumo.code = '500';
142
- sumo.once('warn', (data) => {
143
- data.error.statusCode.should.equal(SYSTEM_ERROR);
144
- data.error.message.should.include('not reachable');
145
- done();
146
- });
147
- sumo.log({ level: 'info', message: 'test 500' });
148
- });
149
-
150
- it('handles other HTTP error status', (done) => {
151
- sumo.code = 'bad';
152
- sumo.once('warn', (data) => {
153
- data.error.statusCode.should.equal(TEAPOT_ERROR);
154
- done();
155
- });
156
- sumo.log({ level: 'info', message: 'test other error' });
157
- });
158
-
159
- it('handles network error without response', (done) => {
160
- sumo.endpoint = 'http://localhost:1/logs/';
161
- sumo.once('warn', (data) => {
162
- data.error.should.have.property('code');
163
- data.error.statusCode.should.equal(SYSTEM_ERROR);
164
- done();
165
- });
166
- sumo.log({ level: 'info', message: 'test network error' });
167
- });
168
-
169
- it('includes correlationId in error response', (done) => {
170
- sumo.code = '401';
171
- sumo.once('warn', (data) => {
172
- data.should.have.property('correlationId', 'test-correlation-id');
173
- done();
174
- });
175
- sumo.log({ level: 'info', message: 'test correlation', [SPLAT]: [{ meta: 'data' }, 'test-correlation-id'] });
176
- });
177
-
178
- it('uses globalThis.serverType when set', (done) => {
179
- globalThis.serverType = 'mSumoRemote';
180
- sumo.once('logged', () => {
181
- delete globalThis.serverType;
182
- done();
183
- });
184
- sumo.log({ level: 'info', message: 'test globalThis' });
185
- });
186
-
187
- it('falls back to unknownServerId when globalThis.serverId is not set', (done) => {
188
- globalThis.serverType = 'mSumoRemote';
189
- sumo.code = '401';
190
- sumo.once('warn', (resp) => {
191
- resp.data.should.have.property('serverType', 'mSumoRemote');
192
- resp.data.should.have.property('serverId', 'unknownServerId@clients');
193
- delete globalThis.serverType;
194
- done();
195
- });
196
- sumo.log({ level: 'info', message: 'test serverId fallback' });
197
- });
198
- });
199
-
200
- describe('S3 transport', function S3Tests() {
201
- this.timeout(TEST_START_TIMEOUT);
202
- beforeEach(() => s3Mock.resetHistory());
203
-
204
- it('sends info logs to S3', (done) => {
205
- logger.info('test s3 info message', { meta: 'data' });
206
- setTimeout(() => {
207
- const calls = s3Mock.commandCalls(PutObjectCommand);
208
- calls.length.should.be.greaterThan(0);
209
- const { Bucket, Key, Body } = calls[0].args[0].input;
210
- Bucket.should.be.a('string');
211
- Key.should.include('info/');
212
- const payload = JSON.parse(Body);
213
- payload.should.be.an('array');
214
- done();
215
- }, TEST_DELAY);
216
- });
217
-
218
- it('sends error logs to S3', (done) => {
219
- logger.error('test s3 error message');
220
- setTimeout(() => {
221
- const calls = s3Mock.commandCalls(PutObjectCommand);
222
- calls.length.should.be.greaterThan(0);
223
- const { Key } = calls[0].args[0].input;
224
- Key.should.include('error/');
225
- done();
226
- }, TEST_DELAY);
227
- });
228
-
229
- it('sends warn logs to S3', (done) => {
230
- logger.warn('test s3 warn message', { meta: 'data' });
231
- setTimeout(() => {
232
- const calls = s3Mock.commandCalls(PutObjectCommand);
233
- calls.length.should.be.greaterThan(0);
234
- const { Key } = calls[0].args[0].input;
235
- Key.should.include('warn/');
236
- done();
237
- }, TEST_DELAY);
238
- });
239
-
240
- it('includes server info in the S3 key', (done) => {
241
- logger.info('test s3 key format');
242
- setTimeout(() => {
243
- const calls = s3Mock.commandCalls(PutObjectCommand);
244
- calls.length.should.be.greaterThan(0);
245
- const { Key } = calls[0].args[0].input;
246
- Key.should.include('mTest/');
247
- Key.should.include('@clients/');
248
- Key.should.match(/\.json$/u);
249
- done();
250
- }, TEST_DELAY);
251
- });
252
-
253
- it('stores log data in S3 body payload', (done) => {
254
- logger.info('test s3 body content', { customField: 'value' });
255
- setTimeout(() => {
256
- const calls = s3Mock.commandCalls(PutObjectCommand);
257
- calls.length.should.be.greaterThan(0);
258
- const payload = JSON.parse(calls[0].args[0].input.Body);
259
- payload.should.be.an('array').with.lengthOf(1);
260
- JSON.parse(payload[0]).should.have.property('message');
261
- JSON.parse(payload[0]).should.have.property('serverType', 'mTest');
262
- done();
263
- }, TEST_DELAY);
264
- });
265
-
266
- it('sends logs with correlationId to S3', (done) => {
267
- logger.info('test s3 with correlation', { meta: 'data' }, correlationId);
268
- setTimeout(() => {
269
- const calls = s3Mock.commandCalls(PutObjectCommand);
270
- calls.length.should.be.greaterThan(0);
271
- const payload = JSON.parse(calls[0].args[0].input.Body);
272
- payload.should.be.an('array').with.lengthOf(1);
273
- JSON.parse(payload[0]).should.have.property('correlationId');
274
- done();
275
- }, TEST_DELAY);
276
- });
277
- });
278
-
279
- describe('S3 remote transport', function S3RemoteTests() {
280
- this.timeout(TEST_START_TIMEOUT);
281
- beforeEach(() => s3Mock.resetHistory());
282
- before(() => {
283
- globalThis.serverType = 'mTestRemote';
284
- globalThis.serverId = 'remoteServerId';
285
- });
286
- after(() => {
287
- delete globalThis.serverType;
288
- delete globalThis.serverId;
289
- });
290
-
291
- it('uses remote key format when globalThis.serverType is set', (done) => {
292
- logger.info('test remote s3 message', { meta: 'data' });
293
- setTimeout(() => {
294
- const calls = s3Mock.commandCalls(PutObjectCommand);
295
- calls.length.should.be.greaterThan(0);
296
- const { Key } = calls[0].args[0].input;
297
- Key.should.include('info/');
298
- Key.should.include('mTestRemote/');
299
- Key.should.include('remoteServerId/');
300
- done();
301
- }, TEST_DELAY);
302
- });
303
-
304
- it('includes serverType in remote S3 body payload', (done) => {
305
- logger.info('test remote s3 body', { meta: 'data' });
306
- setTimeout(() => {
307
- const calls = s3Mock.commandCalls(PutObjectCommand);
308
- calls.length.should.be.greaterThan(0);
309
- const payload = JSON.parse(calls[0].args[0].input.Body);
310
- payload.should.be.an('array');
311
- JSON.parse(payload[0]).should.have.property('serverType', 'mTestRemote');
312
- JSON.parse(payload[0]).should.have.property('serverId', 'remoteServerId');
313
- done();
314
- }, TEST_DELAY);
315
- });
316
-
317
- it('sends remote error logs to S3', (done) => {
318
- logger.error('test remote s3 error');
319
- setTimeout(() => {
320
- const calls = s3Mock.commandCalls(PutObjectCommand);
321
- calls.length.should.be.greaterThan(0);
322
- const { Key } = calls[0].args[0].input;
323
- Key.should.include('error/');
324
- Key.should.include('mTestRemote/');
325
- done();
326
- }, TEST_DELAY);
327
- });
328
- });
329
-
330
- describe('S3 transport flush', function S3FlushTests() {
331
- this.timeout(TEST_START_TIMEOUT);
332
- const HIGH_MAX = 999;
333
- let s3Transport;
334
- let originalMaxEvents;
335
-
336
- before(() => {
337
- s3Transport = logger.transports.find(tr => tr.name === 'awsS3');
338
- originalMaxEvents = s3Transport.maxEvents;
339
- });
340
-
341
- afterEach((done) => {
342
- s3Transport.maxEvents = originalMaxEvents;
343
- s3Mock.reset();
344
- s3Mock.on(PutObjectCommand).resolves({});
345
- delete globalThis.serverType;
346
- delete globalThis.serverId;
347
- s3Transport.flush('flushed').then(() => done());
348
- });
349
-
350
- it('flushes accumulated local events successfully', (done) => {
351
- s3Transport.maxEvents = HIGH_MAX;
352
- logger.info('test flush local');
353
- setTimeout(() => {
354
- s3Mock.resetHistory();
355
- s3Transport.flush('flushed').then(() => {
356
- const calls = s3Mock.commandCalls(PutObjectCommand);
357
- calls.length.should.be.greaterThan(0);
358
- const { Key } = calls[0].args[0].input;
359
- Key.should.include('info/');
360
- done();
361
- });
362
- }, TEST_DELAY);
363
- });
364
-
365
- it('handles flushEvent error gracefully', (done) => {
366
- s3Transport.maxEvents = HIGH_MAX;
367
- logger.info('test flush error');
368
- setTimeout(() => {
369
- s3Mock.reset();
370
- s3Mock.on(PutObjectCommand).rejects(new Error('flush error'));
371
- s3Transport.flush('flushed').then(() => done());
372
- }, TEST_DELAY);
373
- });
374
-
375
- it('flushes accumulated remote type events successfully', (done) => {
376
- globalThis.serverType = 'mFlushRemote';
377
- globalThis.serverId = 'flushServerId';
378
- s3Transport.maxEvents = HIGH_MAX;
379
- logger.info('test flush remote');
380
- setTimeout(() => {
381
- s3Mock.resetHistory();
382
- s3Transport.flush('flushed').then(() => {
383
- const calls = s3Mock.commandCalls(PutObjectCommand);
384
- calls.length.should.be.greaterThan(0);
385
- const { Key } = calls[0].args[0].input;
386
- Key.should.include('mFlushRemote/');
387
- done();
388
- });
389
- }, TEST_DELAY);
390
- });
391
-
392
- it('handles flushTypeEvent with all errors', (done) => {
393
- globalThis.serverType = 'mFlushErr';
394
- globalThis.serverId = 'flushErrId';
395
- s3Transport.maxEvents = HIGH_MAX;
396
- logger.info('test flush remote all errors');
397
- setTimeout(() => {
398
- s3Mock.reset();
399
- s3Mock.on(PutObjectCommand).rejects(new Error('remote flush error'));
400
- s3Transport.flush('flushed').then(() => done());
401
- }, TEST_DELAY);
402
- });
403
-
404
- it('handles flushTypeEvent with partial failure', (done) => {
405
- s3Transport.maxEvents = HIGH_MAX;
406
- globalThis.serverType = 'typeOk';
407
- globalThis.serverId = 'idOk';
408
- logger.info('test flush partial ok');
409
- globalThis.serverType = 'typeFail';
410
- globalThis.serverId = 'idFail';
411
- logger.info('test flush partial fail');
412
- setTimeout(() => {
413
- s3Mock.reset();
414
- s3Mock.on(PutObjectCommand)
415
- .resolvesOnce({})
416
- .rejectsOnce(new Error('partial failure'));
417
- s3Transport.flush('flushed').then(() => done());
418
- }, TEST_DELAY);
419
- });
420
- });
421
-
422
- describe('S3 transport error handling', function S3ErrorTests() {
423
- this.timeout(TEST_START_TIMEOUT);
424
-
425
- afterEach(() => {
426
- s3Mock.reset();
427
- s3Mock.on(PutObjectCommand).resolves({});
428
- delete globalThis.serverType;
429
- delete globalThis.serverId;
430
- });
431
-
432
- it('handles S3 send failure gracefully', (done) => {
433
- s3Mock.on(PutObjectCommand).rejects(new Error('S3 failure'));
434
- logger.info('test s3 send error');
435
- setTimeout(done, TEST_DELAY);
436
- });
437
-
438
- it('handles S3 error level send failure gracefully', (done) => {
439
- s3Mock.on(PutObjectCommand).rejects(new Error('S3 failure'));
440
- logger.error('test s3 error send failure');
441
- setTimeout(done, TEST_DELAY);
442
- });
443
-
444
- it('handles S3 remote send failure gracefully', (done) => {
445
- globalThis.serverType = 'mTestErr';
446
- globalThis.serverId = 'errServerId';
447
- s3Mock.on(PutObjectCommand).rejects(new Error('S3 remote failure'));
448
- logger.info('test s3 remote send error');
449
- setTimeout(done, TEST_DELAY);
450
- });
451
- });
452
-
453
- describe('Circular reference handling', function CircularTests() {
454
- this.timeout(TEST_START_TIMEOUT);
455
- beforeEach(() => {
456
- s3Mock.resetHistory();
457
- kinesisMock.resetHistory();
458
- });
459
-
460
- it('handles logging objects with circular references', (done) => {
461
- const circular = { name: 'test' };
462
- circular.self = circular;
463
- logger.info('test circular reference', circular);
464
- setTimeout(() => {
465
- const s3Calls = s3Mock.commandCalls(PutObjectCommand);
466
- s3Calls.length.should.be.greaterThan(0);
467
- const payload = JSON.parse(s3Calls[0].args[0].input.Body);
468
- payload.should.be.an('array');
469
- JSON.parse(payload[0]).should.have.property('message');
470
- done();
471
- }, TEST_DELAY);
472
- });
473
- });
474
-
475
- describe('Kinesis transport', function KinesisTests() {
476
- this.timeout(TEST_START_TIMEOUT);
477
- beforeEach(() => kinesisMock.resetHistory());
478
-
479
- it('sends info logs to the info stream', (done) => {
480
- logger.info('test kinesis info message', { meta: 'data' });
481
- setTimeout(() => {
482
- const calls = kinesisMock.commandCalls(PutRecordsCommand);
483
- calls.length.should.be.greaterThan(0);
484
- const { StreamName, Records } = calls[0].args[0].input;
485
- StreamName.should.equal('a kinesis stream name for info');
486
- Records.length.should.be.greaterThan(0);
487
- done();
488
- }, TEST_DELAY);
489
- });
490
-
491
- it('sends error logs to the error stream', (done) => {
492
- logger.error('test kinesis error message');
493
- setTimeout(() => {
494
- const calls = kinesisMock.commandCalls(PutRecordsCommand);
495
- const errorCall = calls.find(call => call.args[0].input.StreamName === 'a kinesis stream name for error');
496
- should().exist(errorCall);
497
- done();
498
- }, TEST_DELAY);
499
- });
500
-
501
- it('sends other level logs to the other stream', (done) => {
502
- logger.warn('test kinesis warn message', { meta: 'data' });
503
- setTimeout(() => {
504
- const calls = kinesisMock.commandCalls(PutRecordsCommand);
505
- const otherCall = calls.find(call => call.args[0].input.StreamName === 'a kinesis stream name for other');
506
- should().exist(otherCall);
507
- done();
508
- }, TEST_DELAY);
509
- });
510
- });
511
-
512
- describe('Transport close', function CloseTests() {
513
- this.timeout(TEST_START_TIMEOUT);
514
-
515
- it('clears the S3 interval timer on close', () => {
516
- const s3Transport = logger.transports.find(tr => tr.name === 'awsS3');
517
- (() => s3Transport.close()).should.not.throw();
518
- });
519
-
520
- it('clears the Kinesis interval timer on close', () => {
521
- const kinesisTransport = logger.transports.find(tr => tr.name === 'awsKinesis');
522
- (() => kinesisTransport.close()).should.not.throw();
523
- });
524
- });
525
-
526
- describe('checkMode validation', function CheckModeTests() {
527
- this.timeout(TEST_START_TIMEOUT);
528
-
529
- it('returns null for undefined mode', () => {
530
- should().equal(checkMode(undefined), null);
531
- });
532
-
533
- it('returns null for falsy mode', () => {
534
- should().equal(checkMode(''), null);
535
- });
536
-
537
- it('returns array for a valid single mode', () => {
538
- checkMode('awsS3').should.deep.equal(['awsS3']);
539
- });
540
-
541
- it('parses comma-separated modes', () => {
542
- checkMode('awsS3, sumologic').should.deep.equal(['awsS3', 'sumologic']);
543
- });
544
-
545
- it('expands all mode to sumologic and awsS3', () => {
546
- checkMode('all').should.deep.equal(['sumologic', 'awsS3']);
547
- });
548
-
549
- it('throws when none is combined with other modes', () => {
550
- (() => checkMode('none, awsS3')).should.throw('Cannot have multiple modes');
551
- });
552
-
553
- it('throws for an invalid mode value', () => {
554
- (() => checkMode('invalid')).should.throw('Invalid items in LOG_MODE');
555
- });
556
- });
557
-
558
- describe('checkConfig validation', function CheckConfigTests() {
559
- this.timeout(TEST_START_TIMEOUT);
560
-
561
- it('does not throw for a fully defined config', () => {
562
- (() => checkConfig({ key: 'value', nested: { count: 1 } })).should.not.throw();
563
- });
564
-
565
- it('throws for a config with undefined values', () => {
566
- (() => checkConfig({ key: undefined })).should.throw('Missing values');
567
- });
568
-
569
- it('throws for a nested config with undefined values', () => {
570
- (() => checkConfig({ nested: { key: undefined } })).should.throw('Missing values');
571
- });
572
- });
573
-
574
- describe('parseStack', function ParseStackTests() {
575
- this.timeout(TEST_START_TIMEOUT);
576
-
577
- it('returns a stackInfo object for a valid error', () => {
578
- const result = parseStack(new Error('test'));
579
- should().exist(result);
580
- result.should.have.property('method');
581
- result.should.have.property('path');
582
- result.should.have.property('line');
583
- result.should.have.property('pos');
584
- result.should.have.property('file');
585
- result.should.have.property('stack');
586
- result.should.have.property('hash');
587
- });
588
-
589
- it('produces a 64-character hex hash', () => {
590
- const result = parseStack(new Error('test'));
591
- should().exist(result);
592
- result.hash.should.match(/^[a-f0-9]{64}$/u);
593
- });
594
-
595
- it('returns null when all stack frames are filtered out', () => {
596
- const fakeError = { stack: 'Error\n at Object.<anonymous> (node_modules/winston/foo.js:1:1)' };
597
- const result = parseStack(fakeError);
598
- should().equal(result, null);
599
- });
600
- });
@@ -1,84 +0,0 @@
1
- import './testEnvProdFilter.js';
2
- import { OK_EXIT, TEST_FLUSH_TIMEOUT, TEST_START_TIMEOUT } from '../lib/common.js';
3
- import { after, describe, it } from 'mocha';
4
- import { getCorrelationId } from '@mimik/request-helper';
5
- import logger from '../index.js';
6
- import process from 'node:process';
7
- import { setTimeout } from 'node:timers';
8
- import { should } from 'chai';
9
- import { stub } from 'sinon';
10
-
11
- const correlationId = getCorrelationId('--sumologic-winston-logger-prod-test--');
12
-
13
- const user = {
14
- __v: 1,
15
- _id: '5d28b615a97b3605636a9e17',
16
- appIds: [],
17
- attributes: [{
18
- name: 'nickname',
19
- value: 'User 5',
20
- }],
21
- avatar: 'https://mts.mimik360.com/mTS/v1/thumbnails/9a86220f-9d76-48e4-98a3-1a51c22fc49a',
22
- createdAt: '2019-07-12T16:32:21.709Z',
23
- email: 'test@test.com',
24
- externalIds: [
25
- '2584799985283928064',
26
- ],
27
- id: '2584799985283928064',
28
- references: [{
29
- serverType: 'mFD',
30
- resourceName: 'requestFriendLists',
31
- include: 'requestFriends',
32
- id: '2584799985283928064',
33
- self: 'https://mfd.mimik360.com/mFD/v1/requestFriendLists/2584799985283928064',
34
- },
35
- {
36
- serverType: 'mFD',
37
- resourceName: 'friendRequestLists',
38
- include: 'friendRequests',
39
- id: '2584799985283928064',
40
- self: 'https://mfd.mimik360.com/mFD/v1/friendRequestLists/2584799985283928064',
41
- },
42
- {
43
- serverType: 'mFD',
44
- resourceName: 'friendLists',
45
- include: 'friends',
46
- id: '2584799985283928064',
47
- self: 'https://mfd.mimik360.com/mFD/v1/friendLists/2584799985283928064',
48
- },
49
- {
50
- serverType: 'mDS',
51
- resourceName: 'nodes',
52
- include: 'devices',
53
- id: '2584799985283928064',
54
- self: 'https://mds.mimik360.com/mDS/v1/nodes?accountId=2584799985283928064',
55
- }],
56
- self: 'https://mpo.mimik360.com/mPO/v1/users/2584799985283928064',
57
- updatedAt: '2019-07-12T16:35:39.195Z',
58
- };
59
-
60
- should();
61
-
62
- describe('sumologic-winston-logger prod filter tests', function LoggerTests() {
63
- this.timeout(TEST_START_TIMEOUT);
64
- it('Changing the environment to prod to cover filters', () => {
65
- logger.info('this is an info statement on prod', { meta: 'data' });
66
- });
67
- it('Changing the environment to prod to cover filters and see filtered result', () => {
68
- logger.info('this is an info statement on prod', { user }, correlationId);
69
- });
70
- it('Can log a debug statement without correlationId and info on production', () => {
71
- logger.debug('this is a debug statement');
72
- });
73
- it('Can flush and exit', (done) => {
74
- logger.debug('this is a debug statement');
75
- stub(process, 'exit');
76
- logger.flushAndExit(OK_EXIT);
77
- done();
78
- });
79
- after(done => setTimeout(() => { // adding a delay to make sure that the flush is done
80
- clearTimeout(logger.safetyTimer);
81
- process.exit.restore();
82
- done();
83
- }, TEST_FLUSH_TIMEOUT));
84
- });