chore: clean up macOS preview log output (#2823)
This commit is contained in:
@@ -550,8 +550,37 @@ This is only applicable when previewing Android releases.''',
|
||||
final logs = await open.newApplication(path: appDirectory.path);
|
||||
final completer = Completer<void>();
|
||||
|
||||
// Filter out extra noise from the logs.
|
||||
final logFilters = [
|
||||
RegExp(r'\[com\.apple.*\]'),
|
||||
RegExp(r'\(RunningBoardServices\)'),
|
||||
RegExp(r'\(CoreFoundation\)'),
|
||||
RegExp(r'\(TCC\)'),
|
||||
RegExp(r'\(Metal\)'),
|
||||
RegExp('^Timestamp'),
|
||||
RegExp('^Filtering the log data'),
|
||||
];
|
||||
|
||||
// Removes the log prefix from the log line.
|
||||
// Example log line:
|
||||
// ignore: lines_longer_than_80_chars
|
||||
// 2025-01-31 09:53:22.889 Df macos_sandbox[22535:1d268] [dev.shorebird:updater::cache::patch_manager] [shorebird] No public key provided, skipping signature verification
|
||||
final prefixRegex = RegExp(
|
||||
r'^[\d-]+\W+[\d:\.]+\W+\w+\W+\w+\[[\da-f]+:[\da-f]+\]',
|
||||
);
|
||||
String removeLogPrefix(String line) {
|
||||
return line.trim().replaceFirst(prefixRegex, '').trim();
|
||||
}
|
||||
|
||||
logs.listen(
|
||||
(log) => logger.info(utf8.decode(log)),
|
||||
(log) {
|
||||
final logLine = utf8.decode(log);
|
||||
if (logFilters.any((filter) => filter.hasMatch(logLine))) {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info(removeLogPrefix(logLine));
|
||||
},
|
||||
onDone: completer.complete,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// cspell:words libinfo networkd
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io' hide Platform;
|
||||
@@ -2146,6 +2147,46 @@ channel: ${DeploymentTrack.staging.channel}
|
||||
verify(() => logger.info('hello world')).called(1);
|
||||
});
|
||||
});
|
||||
|
||||
group('log output', () {
|
||||
final rawLogOutput = '''
|
||||
2025-01-31 10:15:29.807 Df macos_sandbox[33557:2cc3d] [com.apple.network:] networkd_settings_read_from_file initialized networkd settings by reading plist directly
|
||||
|
||||
2025-01-31 10:15:29.807 Df macos_sandbox[33557:2cc3d] [com.apple.network:path] nw_path_libinfo_path_check [5E11C960-BB0A-456A-8024-620DAB6CCF17 Hostname#941210b4:0 tcp, legacy-socket, attribution: developer]
|
||||
libinfo check path: satisfied (Path is satisfied), interface: en0, ipv4, dns
|
||||
|
||||
2025-01-31 10:15:29.808 Df macos_sandbox[33557:2cc12] [dev.shorebird:updater::updater] [shorebird] Reporting successful launch.
|
||||
'''
|
||||
.split('\n');
|
||||
|
||||
setUp(() {
|
||||
setupMacosShorebirdYaml();
|
||||
when(() => open.newApplication(path: any(named: 'path'))).thenAnswer(
|
||||
(_) async => Stream.fromIterable(rawLogOutput.map(utf8.encode)),
|
||||
);
|
||||
});
|
||||
|
||||
test('removes noisy lines from log output', () async {
|
||||
final result = await runWithOverrides(command.run);
|
||||
expect(result, equals(ExitCode.success.code));
|
||||
|
||||
verify(
|
||||
() => logger.info(
|
||||
'''[dev.shorebird:updater::updater] [shorebird] Reporting successful launch.''',
|
||||
),
|
||||
).called(1);
|
||||
verifyNever(
|
||||
() => logger.info(
|
||||
any(that: contains('networkd_settings_read_from_file')),
|
||||
),
|
||||
);
|
||||
verifyNever(
|
||||
() => logger.info(
|
||||
any(that: contains('nw_path_libinfo_path_check')),
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
group('windows', () {
|
||||
|
||||
Reference in New Issue
Block a user