Skip to content

Commit

Permalink
Collect log message count and log at the end (#2430)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliette authored May 14, 2024
1 parent 99abc53 commit fc32eb6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 13 additions & 3 deletions dwds/lib/src/debugging/debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class Debugger extends Domain {
final Locations _locations;
final SkipLists _skipLists;

int _frameErrorCount = 0;

Debugger._(
this._remoteDebugger,
this._streamNotify,
Expand Down Expand Up @@ -465,15 +467,23 @@ class Debugger extends Domain {
try {
dartFrame.vars = await variablesFor(frame);
} catch (e) {
logger.warning(
'Error calculating Dart variables for frame $frameIndex: $e',
);
_frameErrorCount++;
}
}

return dartFrame;
}

/// Can be called after [calculateDartFrameFor] to log any errors.
void logAnyFrameErrors({required String frameType}) {
if (_frameErrorCount > 0) {
logger.warning(
'Error calculating Dart variables for $_frameErrorCount $frameType frames.',
);
}
_frameErrorCount = 0;
}

void _scriptParsedHandler(ScriptParsedEvent e) {
final scriptPath = _pathForChromeScript(e.script.url);
if (scriptPath != null) {
Expand Down
2 changes: 2 additions & 0 deletions dwds/lib/src/debugging/frame_computer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class FrameComputer {
logger.warning('Error calculating sync frame: $e');
}
}
debugger.logAnyFrameErrors(frameType: 'sync');
}

Future<void> _collectAsyncFrames({int? limit}) async {
Expand Down Expand Up @@ -129,6 +130,7 @@ class FrameComputer {
logger.warning('Error calculating async frame: $e');
}
}
debugger.logAnyFrameErrors(frameType: 'async');
}

// Async frames are no longer on the stack - we don't have local variable
Expand Down

0 comments on commit fc32eb6

Please sign in to comment.