Unverified Commit d911eadf authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] create NotifyingLogger at the top level when running flutter...

[flutter_tools] create NotifyingLogger at the top level when running flutter run --machine or flutter attach --machine (#59087)

Removes dependency on injecting additional logger with zones
parent afe8bf7c
...@@ -65,7 +65,9 @@ Future<void> main(List<String> args) async { ...@@ -65,7 +65,9 @@ Future<void> main(List<String> args) async {
(args.isNotEmpty && args.first == 'help') || (args.length == 1 && verbose); (args.isNotEmpty && args.first == 'help') || (args.length == 1 && verbose);
final bool muteCommandLogging = help || doctor; final bool muteCommandLogging = help || doctor;
final bool verboseHelp = help && verbose; final bool verboseHelp = help && verbose;
final bool daemon = args.contains('daemon'); final bool daemon = args.contains('daemon') ||
(args.contains('--machine') && args.contains('run')) ||
(args.contains('--machine') && args.contains('attach'));
await runner.run(args, () => <FlutterCommand>[ await runner.run(args, () => <FlutterCommand>[
AnalyzeCommand( AnalyzeCommand(
......
...@@ -783,6 +783,13 @@ class SilentStatus extends Status { ...@@ -783,6 +783,13 @@ class SilentStatus extends Status {
timeoutConfiguration: timeoutConfiguration, timeoutConfiguration: timeoutConfiguration,
stopwatch: stopwatch, stopwatch: stopwatch,
); );
@override
void finish() {
if (onFinish != null) {
onFinish();
}
}
} }
/// Constructor writes [message] to [stdout]. On [cancel] or [stop], will call /// Constructor writes [message] to [stdout]. On [cancel] or [stop], will call
......
...@@ -207,7 +207,9 @@ class AttachCommand extends FlutterCommand { ...@@ -207,7 +207,9 @@ class AttachCommand extends FlutterCommand {
? Daemon( ? Daemon(
stdinCommandStream, stdinCommandStream,
stdoutCommandResponse, stdoutCommandResponse,
notifyingLogger: NotifyingLogger(verbose: globals.logger.isVerbose), notifyingLogger: (globals.logger is NotifyingLogger)
? globals.logger as NotifyingLogger
: NotifyingLogger(verbose: globals.logger.isVerbose),
logToStdout: true, logToStdout: true,
) )
: null; : null;
......
...@@ -415,7 +415,9 @@ class RunCommand extends RunCommandBase { ...@@ -415,7 +415,9 @@ class RunCommand extends RunCommandBase {
final Daemon daemon = Daemon( final Daemon daemon = Daemon(
stdinCommandStream, stdinCommandStream,
stdoutCommandResponse, stdoutCommandResponse,
notifyingLogger: NotifyingLogger(verbose: globals.logger.isVerbose), notifyingLogger: (globals.logger is NotifyingLogger)
? globals.logger as NotifyingLogger
: NotifyingLogger(verbose: globals.logger.isVerbose),
logToStdout: true, logToStdout: true,
); );
AppInstance app; AppInstance app;
......
...@@ -35,4 +35,26 @@ void main() { ...@@ -35,4 +35,26 @@ void main() {
// Only printed by verbose tool. // Only printed by verbose tool.
expect(result.stdout, isNot(contains('exiting with code 0'))); expect(result.stdout, isNot(contains('exiting with code 0')));
}); });
test('flutter run --machine uses NotifyingLogger', () async {
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
final ProcessResult result = await const LocalProcessManager().run(<String>[
flutterBin,
'run',
'--machine',
]);
expect(result.stdout, isEmpty);
});
test('flutter attach --machine uses NotifyingLogger', () async {
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
final ProcessResult result = await const LocalProcessManager().run(<String>[
flutterBin,
'attach',
'--machine',
]);
expect(result.stdout, isEmpty);
});
} }
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