Commit 05113d58 authored by Devon Carew's avatar Devon Carew

fix an issue with logging ios simulator output

parent b2c710dd
...@@ -50,7 +50,7 @@ class LogsCommand extends FlutterCommand { ...@@ -50,7 +50,7 @@ class LogsCommand extends FlutterCommand {
readers.add(device.createLogReader()); readers.add(device.createLogReader());
} }
printStatus('Logging for ${readers.join(', ')}...'); printStatus('Showing logs for ${readers.join(', ')}:');
List<int> results = await Future.wait(readers.map((DeviceLogReader reader) async { List<int> results = await Future.wait(readers.map((DeviceLogReader reader) async {
int result = await reader.logs(clear: clear); int result = await reader.logs(clear: clear);
......
...@@ -377,8 +377,11 @@ class IOSSimulator extends Device { ...@@ -377,8 +377,11 @@ class IOSSimulator extends Device {
void clearLogs() { void clearLogs() {
File logFile = new File(logFilePath); File logFile = new File(logFilePath);
if (logFile.existsSync()) if (logFile.existsSync()) {
logFile.delete(); RandomAccessFile randomFile = logFile.openSync(mode: FileMode.WRITE);
randomFile.truncateSync(0);
randomFile.closeSync();
}
} }
} }
...@@ -419,7 +422,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader { ...@@ -419,7 +422,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
String get name => device.name; String get name => device.name;
Future<int> logs({bool clear: false}) async { Future<int> logs({ bool clear: false }) async {
if (!device.isConnected()) if (!device.isConnected())
return 2; return 2;
...@@ -430,7 +433,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader { ...@@ -430,7 +433,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
// 'Jan 29 01:31:44 devoncarew-macbookpro3 SpringBoard[96648]: ...' // 'Jan 29 01:31:44 devoncarew-macbookpro3 SpringBoard[96648]: ...'
RegExp mapRegex = new RegExp(r'\S+ +\S+ +\S+ \S+ (.+)\[\d+\]\)?: (.*)$'); 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 ---
RegExp lastMessageRegex = new RegExp(r'\S+ +\S+ +\S+ (--- .* ---)$'); RegExp lastMessageRegex = new RegExp(r'\S+ +\S+ +\S+ --- (.*) ---$');
// This filter matches many Flutter lines in the log: // This filter matches many Flutter lines in the log:
// new RegExp(r'(FlutterRunner|flutter.runner.Runner|$id)'), but it misses // new RegExp(r'(FlutterRunner|flutter.runner.Runner|$id)'), but it misses
...@@ -450,11 +453,13 @@ class _IOSSimulatorLogReader extends DeviceLogReader { ...@@ -450,11 +453,13 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
String content = match.group(2); String content = match.group(2);
if (category == 'Game Center' || category == 'itunesstored' || category == 'nanoregistrylaunchd') if (category == 'Game Center' || category == 'itunesstored' || category == 'nanoregistrylaunchd')
return null; return null;
if (category == 'FlutterRunner')
return content;
return '$category: $content'; return '$category: $content';
} }
match = lastMessageRegex.matchAsPrefix(string); match = lastMessageRegex.matchAsPrefix(string);
if (match != null) if (match != null)
return match.group(1); return '(${match.group(1)})';
return string; return string;
} }
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment