@@ -1363,8 +1363,6 @@ ${globalToolConfiguration.loadStrategy.loadModuleSnippet}("dart_sdk").developer.
1363
1363
1364
1364
final args = event.args;
1365
1365
final firstArgValue = (args.isNotEmpty ? args[0 ].value : null ) as String ? ;
1366
- // TODO(nshahan) - Migrate 'inspect' and 'log' events to the injected
1367
- // client communication approach as well?
1368
1366
switch (firstArgValue) {
1369
1367
case 'dart.developer.inspect' :
1370
1368
// All inspected objects should be real objects.
@@ -1383,7 +1381,13 @@ ${globalToolConfiguration.loadStrategy.loadModuleSnippet}("dart_sdk").developer.
1383
1381
);
1384
1382
break ;
1385
1383
case 'dart.developer.log' :
1386
- await _handleDeveloperLog (isolateRef, event);
1384
+ await _handleDeveloperLog (isolateRef, event).catchError (
1385
+ (error, stackTrace) => _logger.warning (
1386
+ 'Error handling developer log:' ,
1387
+ error,
1388
+ stackTrace,
1389
+ ),
1390
+ );
1387
1391
break ;
1388
1392
default :
1389
1393
break ;
@@ -1402,12 +1406,13 @@ ${globalToolConfiguration.loadStrategy.loadModuleSnippet}("dart_sdk").developer.
1402
1406
ConsoleAPIEvent event,
1403
1407
) async {
1404
1408
final logObject = event.params? ['args' ][1 ] as Map ? ;
1405
- final logParams = < String , RemoteObject > {};
1406
- for (dynamic obj in logObject? ['preview' ]? ['properties' ] ?? {}) {
1407
- if (obj['name' ] != null && obj is Map <String , dynamic >) {
1408
- logParams[obj['name' ] as String ] = RemoteObject (obj);
1409
- }
1410
- }
1409
+ final objectId = logObject? ['objectId' ];
1410
+ // Always attempt to fetch the full properties instead of relying on
1411
+ // `RemoteObject.preview` which only has truncated log messages:
1412
+ // https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#type-RemoteObject
1413
+ final logParams = objectId != null
1414
+ ? await _fetchFullLogParams (objectId, logObject: logObject)
1415
+ : _fetchAbbreviatedLogParams (logObject);
1411
1416
1412
1417
final logRecord = LogRecord (
1413
1418
message: await _instanceRef (logParams['message' ]),
@@ -1436,6 +1441,37 @@ ${globalToolConfiguration.loadStrategy.loadModuleSnippet}("dart_sdk").developer.
1436
1441
);
1437
1442
}
1438
1443
1444
+ Future <Map <String , RemoteObject >> _fetchFullLogParams (
1445
+ String objectId, {
1446
+ required Map ? logObject,
1447
+ }) async {
1448
+ final logParams = < String , RemoteObject > {};
1449
+ for (final property in await inspector.getProperties (objectId)) {
1450
+ final name = property.name;
1451
+ final value = property.value;
1452
+ if (name != null && value != null ) {
1453
+ logParams[name] = value;
1454
+ }
1455
+ }
1456
+
1457
+ // If for some reason we don't get the full log params, then return the
1458
+ // abbreviated version instead:
1459
+ if (logParams.isEmpty) {
1460
+ return _fetchAbbreviatedLogParams (logObject);
1461
+ }
1462
+ return logParams;
1463
+ }
1464
+
1465
+ Map <String , RemoteObject > _fetchAbbreviatedLogParams (Map ? logObject) {
1466
+ final logParams = < String , RemoteObject > {};
1467
+ for (dynamic property in logObject? ['preview' ]? ['properties' ] ?? []) {
1468
+ if (property is Map <String , dynamic > && property['name' ] != null ) {
1469
+ logParams[property['name' ] as String ] = RemoteObject (property);
1470
+ }
1471
+ }
1472
+ return logParams;
1473
+ }
1474
+
1439
1475
@override
1440
1476
Future <Timestamp > getVMTimelineMicros () {
1441
1477
return _rpcNotSupportedFuture ('getVMTimelineMicros' );
0 commit comments