@@ -421,11 +421,9 @@ export function stringifyWithMaxLen(
421
421
strToTruncate =
422
422
typeof value !== 'function'
423
423
? EJSON . stringify ( value , options )
424
- : value . name !== ''
425
- ? value . name
426
- : 'anonymous function' ;
424
+ : 'ReadPreference function' ;
427
425
} catch ( e ) {
428
- strToTruncate = `... ESJON failed : Error ${ e . message } ` ;
426
+ strToTruncate = `Extended JSON serialization failed with: ${ e . message } ` ;
429
427
}
430
428
431
429
return maxDocumentLength !== 0 && strToTruncate . length > maxDocumentLength
@@ -463,7 +461,7 @@ function attachCommandFields(
463
461
log . commandName = commandEvent . commandName ;
464
462
log . requestId = commandEvent . requestId ;
465
463
log . driverConnectionId = commandEvent . connectionId ;
466
- const { host, port } = HostAddress . fromString ( commandEvent . address ?? '' ) . toHostPort ( ) ;
464
+ const { host, port } = HostAddress . fromString ( commandEvent . address ) . toHostPort ( ) ;
467
465
log . serverHost = host ;
468
466
log . serverPort = port ;
469
467
if ( commandEvent ?. serviceId ) {
@@ -476,7 +474,7 @@ function attachCommandFields(
476
474
}
477
475
478
476
function attachConnectionFields ( log : Record < string , any > , event : any ) {
479
- const { host, port } = HostAddress . fromString ( event . address ?? '' ) . toHostPort ( ) ;
477
+ const { host, port } = HostAddress . fromString ( event . address ) . toHostPort ( ) ;
480
478
log . serverHost = host ;
481
479
log . serverPort = port ;
482
480
@@ -498,7 +496,7 @@ function attachServerHeartbeatFields(
498
496
const { awaited, connectionId } = serverHeartbeatEvent ;
499
497
log . awaited = awaited ;
500
498
log . driverConnectionId = serverHeartbeatEvent . connectionId ;
501
- const { host, port } = HostAddress . fromString ( connectionId ?? '' ) . toHostPort ( ) ;
499
+ const { host, port } = HostAddress . fromString ( connectionId ) . toHostPort ( ) ;
502
500
log . serverHost = host ;
503
501
log . serverPort = port ;
504
502
return log ;
0 commit comments