handle 'last message repeated' from ios simulator (#4300)
This commit is contained in:
parent
8171aa86f0
commit
7ae584bc02
@ -5,6 +5,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
@ -700,7 +701,6 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
|
|||||||
final IOSSimulator device;
|
final IOSSimulator device;
|
||||||
|
|
||||||
StreamController<String> _linesController;
|
StreamController<String> _linesController;
|
||||||
bool _lastWasFiltered = false;
|
|
||||||
|
|
||||||
// We log from two files: the device and the system log.
|
// We log from two files: the device and the system log.
|
||||||
Process _deviceProcess;
|
Process _deviceProcess;
|
||||||
@ -736,15 +736,14 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
|
|||||||
static final RegExp _mapRegex = new RegExp(r'\S+ +\S+ +\S+ \S+ (.+)\[\d+\]\)?: (.*)$');
|
static final RegExp _mapRegex = new RegExp(r'\S+ +\S+ +\S+ \S+ (.+)\[\d+\]\)?: (.*)$');
|
||||||
|
|
||||||
// Jan 31 19:23:28 --- last message repeated 1 time ---
|
// Jan 31 19:23:28 --- last message repeated 1 time ---
|
||||||
static final RegExp _lastMessageRegex = new RegExp(r'\S+ +\S+ +\S+ --- (.*) ---$');
|
static final RegExp _lastMessageSingleRegex = new RegExp(r'\S+ +\S+ +\S+ --- last message repeated 1 time ---$');
|
||||||
|
static final RegExp _lastMessageMultipleRegex = new RegExp(r'\S+ +\S+ +\S+ --- last message repeated (\d+) times ---$');
|
||||||
|
|
||||||
static final RegExp _flutterRunnerRegex = new RegExp(r' FlutterRunner\[\d+\] ');
|
static final RegExp _flutterRunnerRegex = new RegExp(r' FlutterRunner\[\d+\] ');
|
||||||
|
|
||||||
String _filterDeviceLine(String string) {
|
String _filterDeviceLine(String string) {
|
||||||
Match match = _mapRegex.matchAsPrefix(string);
|
Match match = _mapRegex.matchAsPrefix(string);
|
||||||
if (match != null) {
|
if (match != null) {
|
||||||
_lastWasFiltered = true;
|
|
||||||
|
|
||||||
// Filter out some messages that clearly aren't related to Flutter.
|
// Filter out some messages that clearly aren't related to Flutter.
|
||||||
if (string.contains(': could not find icon for representation -> com.apple.'))
|
if (string.contains(': could not find icon for representation -> com.apple.'))
|
||||||
return null;
|
return null;
|
||||||
@ -762,23 +761,33 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
|
|||||||
&& content.endsWith(']: 0x1'))
|
&& content.endsWith(']: 0x1'))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
_lastWasFiltered = false;
|
|
||||||
|
|
||||||
if (category == 'Runner')
|
if (category == 'Runner')
|
||||||
return content;
|
return content;
|
||||||
return '$category: $content';
|
return '$category: $content';
|
||||||
}
|
}
|
||||||
match = _lastMessageRegex.matchAsPrefix(string);
|
match = _lastMessageSingleRegex.matchAsPrefix(string);
|
||||||
if (match != null && !_lastWasFiltered)
|
if (match != null)
|
||||||
return '(${match.group(1)})';
|
return null;
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _lastLine;
|
||||||
|
|
||||||
void _onDeviceLine(String line) {
|
void _onDeviceLine(String line) {
|
||||||
String filteredLine = _filterDeviceLine(line);
|
Match multi = _lastMessageMultipleRegex.matchAsPrefix(line);
|
||||||
if (filteredLine == null)
|
|
||||||
return;
|
if (multi != null) {
|
||||||
_linesController.add(filteredLine);
|
if (_lastLine != null) {
|
||||||
|
int repeat = int.parse(multi.group(1));
|
||||||
|
repeat = math.max(0, math.min(100, repeat));
|
||||||
|
for (int i = 0; i < repeat; i++)
|
||||||
|
_linesController.add(_lastLine);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_lastLine = _filterDeviceLine(line);
|
||||||
|
if (_lastLine != null)
|
||||||
|
_linesController.add(_lastLine);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String _filterSystemLog(String string) {
|
String _filterSystemLog(String string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user