@@ -443,9 +443,8 @@ describe('class MongoLogger', async function () {
443
443
const log : Log = { t : new Date ( ) , c : 'command' , s : 'error' } ;
444
444
options . logDestination . write ( log ) ;
445
445
446
- expect ( stderrStub . write ) . to . have . been . calledOnceWith (
447
- inspect ( log , { breakLength : Infinity , compact : true } )
448
- ) ;
446
+ const logLine = inspect ( log , { breakLength : Infinity , compact : true } ) ;
447
+ expect ( stderrStub . write ) . to . have . been . calledOnceWith ( `${ logLine } \n` ) ;
449
448
} ) ;
450
449
}
451
450
}
@@ -465,9 +464,8 @@ describe('class MongoLogger', async function () {
465
464
const log : Log = { t : new Date ( ) , c : 'command' , s : 'error' } ;
466
465
options . logDestination . write ( log ) ;
467
466
468
- expect ( stderrStub . write ) . to . have . been . calledOnceWith (
469
- inspect ( log , { breakLength : Infinity , compact : true } )
470
- ) ;
467
+ const logLine = inspect ( log , { breakLength : Infinity , compact : true } ) ;
468
+ expect ( stderrStub . write ) . to . have . been . calledOnceWith ( `${ logLine } \n` ) ;
471
469
} ) ;
472
470
}
473
471
}
@@ -512,9 +510,8 @@ describe('class MongoLogger', async function () {
512
510
const log : Log = { t : new Date ( ) , c : 'command' , s : 'error' } ;
513
511
options . logDestination . write ( log ) ;
514
512
515
- expect ( stderrStub . write ) . to . have . been . calledOnceWith (
516
- inspect ( log , { breakLength : Infinity , compact : true } )
517
- ) ;
513
+ const logLine = inspect ( log , { breakLength : Infinity , compact : true } ) ;
514
+ expect ( stderrStub . write ) . to . have . been . calledOnceWith ( `${ logLine } \n` ) ;
518
515
} ) ;
519
516
}
520
517
}
@@ -536,9 +533,8 @@ describe('class MongoLogger', async function () {
536
533
const log : Log = { t : new Date ( ) , c : 'command' , s : 'error' } ;
537
534
options . logDestination . write ( log ) ;
538
535
539
- expect ( stderrStub . write ) . to . have . been . calledOnceWith (
540
- inspect ( log , { breakLength : Infinity , compact : true } )
541
- ) ;
536
+ const logLine = inspect ( log , { breakLength : Infinity , compact : true } ) ;
537
+ expect ( stderrStub . write ) . to . have . been . calledOnceWith ( `${ logLine } \n` ) ;
542
538
} ) ;
543
539
}
544
540
}
@@ -1399,9 +1395,8 @@ describe('class MongoLogger', async function () {
1399
1395
logger . debug ( 'client' , 'random message' ) ;
1400
1396
let stderrStubCall = stderrStub . write . getCall ( 0 ) . args [ 0 ] ;
1401
1397
stderrStubCall = stderrStubCall . slice ( stderrStubCall . search ( 'c:' ) ) ;
1402
- expect ( stderrStubCall ) . to . equal (
1403
- `c: 'client', s: 'error', message: 'User input for mongodbLogPath is now invalid. Logging is halted.', error: 'This writable always throws' }`
1404
- ) ;
1398
+ const expectedLogLine1 = `c: 'client', s: 'error', message: 'User input for mongodbLogPath is now invalid. Logging is halted.', error: 'This writable always throws' }` ;
1399
+ expect ( stderrStubCall ) . to . equal ( `${ expectedLogLine1 } \n` ) ;
1405
1400
1406
1401
// logging is halted
1407
1402
logger . debug ( 'client' , 'random message 2' ) ;
@@ -1450,9 +1445,8 @@ describe('class MongoLogger', async function () {
1450
1445
// stderr now contains the error message
1451
1446
let stderrStubCall = stderrStub . write . getCall ( 0 ) . args [ 0 ] ;
1452
1447
stderrStubCall = stderrStubCall . slice ( stderrStubCall . search ( 'c:' ) ) ;
1453
- expect ( stderrStubCall ) . to . equal (
1454
- `c: 'client', s: 'error', message: 'User input for mongodbLogPath is now invalid. Logging is halted.', error: 'This writable always throws, but only after at least 500ms' }`
1455
- ) ;
1448
+ const expectedLogLine1 = `c: 'client', s: 'error', message: 'User input for mongodbLogPath is now invalid. Logging is halted.', error: 'This writable always throws, but only after at least 500ms' }` ;
1449
+ expect ( stderrStubCall ) . to . equal ( `${ expectedLogLine1 } \n` ) ;
1456
1450
1457
1451
// no more logging in the future
1458
1452
logger . debug ( 'client' , 'random message 2' ) ;
@@ -1480,7 +1474,7 @@ describe('class MongoLogger', async function () {
1480
1474
let stderrStubCall = stderrStub . write . getCall ( 0 ) . args [ 0 ] ;
1481
1475
stderrStubCall = stderrStubCall . slice ( stderrStubCall . search ( 'c:' ) ) ;
1482
1476
expect ( stderrStubCall ) . to . equal (
1483
- `c: 'client', s: 'error', message: 'User input for mongodbLogPath is now invalid. Logging is halted.', error: 'I am stdout and do not work' }`
1477
+ `c: 'client', s: 'error', message: 'User input for mongodbLogPath is now invalid. Logging is halted.', error: 'I am stdout and do not work' }\n `
1484
1478
) ;
1485
1479
1486
1480
// logging is halted
0 commit comments