mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
adjust adb logcat filter (#4104)
This commit is contained in:
parent
40179aaa1c
commit
17b9c12b80
@ -522,6 +522,8 @@ class _AdbLogReader extends DeviceLogReader {
|
|||||||
|
|
||||||
final AndroidDevice device;
|
final AndroidDevice device;
|
||||||
|
|
||||||
|
bool _lastWasFiltered = false;
|
||||||
|
|
||||||
StreamController<String> _linesController;
|
StreamController<String> _linesController;
|
||||||
Process _process;
|
Process _process;
|
||||||
|
|
||||||
@ -537,9 +539,6 @@ class _AdbLogReader extends DeviceLogReader {
|
|||||||
String lastTimestamp = device.lastLogcatTimestamp;
|
String lastTimestamp = device.lastLogcatTimestamp;
|
||||||
if (lastTimestamp != null)
|
if (lastTimestamp != null)
|
||||||
args.addAll(<String>['-T', lastTimestamp]);
|
args.addAll(<String>['-T', lastTimestamp]);
|
||||||
args.addAll(<String>[
|
|
||||||
'-s', 'flutter:V', 'FlutterMain:V', 'FlutterView:V', 'AndroidRuntime:W', 'ActivityManager:W', 'System.err:W', '*:F'
|
|
||||||
]);
|
|
||||||
runCommand(device.adbCommandForDevice(args)).then((Process process) {
|
runCommand(device.adbCommandForDevice(args)).then((Process process) {
|
||||||
_process = process;
|
_process = process;
|
||||||
_process.stdout.transform(UTF8.decoder).transform(const LineSplitter()).listen(_onLine);
|
_process.stdout.transform(UTF8.decoder).transform(const LineSplitter()).listen(_onLine);
|
||||||
@ -552,11 +551,38 @@ class _AdbLogReader extends DeviceLogReader {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 'W/ActivityManager: '
|
||||||
|
static final RegExp _logFormat = new RegExp(r'^[VDIWEF]\/[^:]+:\s+');
|
||||||
|
|
||||||
|
static final List<RegExp> _whitelistedTags = <RegExp>[
|
||||||
|
new RegExp(r'^[VDIWEF]\/flutter[^:]*:\s+', caseSensitive: false),
|
||||||
|
new RegExp(r'^[WEF]\/AndroidRuntime:\s+'),
|
||||||
|
new RegExp(r'^[WEF]\/ActivityManager:\s+'),
|
||||||
|
new RegExp(r'^[WEF]\/System\.err:\s+'),
|
||||||
|
new RegExp(r'^[F]\/[\S^:]+:\s+')
|
||||||
|
];
|
||||||
|
|
||||||
void _onLine(String line) {
|
void _onLine(String line) {
|
||||||
|
if (_logFormat.hasMatch(line)) {
|
||||||
// Filter out some noisy ActivityManager notifications.
|
// Filter out some noisy ActivityManager notifications.
|
||||||
if (line.startsWith('W/ActivityManager: getRunningAppProcesses'))
|
if (line.startsWith('W/ActivityManager: getRunningAppProcesses'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Filter on approved names and levels.
|
||||||
|
for (RegExp regex in _whitelistedTags) {
|
||||||
|
if (regex.hasMatch(line)) {
|
||||||
|
_lastWasFiltered = false;
|
||||||
_linesController.add(line);
|
_linesController.add(line);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastWasFiltered = true;
|
||||||
|
} else {
|
||||||
|
// If it doesn't match the log pattern at all, pass it through.
|
||||||
|
if (!_lastWasFiltered)
|
||||||
|
_linesController.add(line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _stop() {
|
void _stop() {
|
||||||
|
Loading…
Reference in New Issue
Block a user