mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

* Update project.pbxproj files to say Flutter rather than Chromium Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright. * Update the copyright notice checker to require a standard notice on all files * Update copyrights on Dart files. (This was a mechanical commit.) * Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine. Some were already marked "The Flutter Authors", not clear why. Their dates have been normalized. Some were missing the blank line after the license. Some were randomly different in trivial ways for no apparent reason (e.g. missing the trailing period). * Clean up the copyrights in non-Dart files. (Manual edits.) Also, make sure templates don't have copyrights. * Fix some more ORGANIZATIONNAMEs
89 lines
2.3 KiB
Dart
89 lines
2.3 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'dart:async';
|
|
|
|
import '../base/common.dart';
|
|
import '../base/io.dart';
|
|
import '../cache.dart';
|
|
import '../device.dart';
|
|
import '../globals.dart';
|
|
import '../runner/flutter_command.dart';
|
|
|
|
class LogsCommand extends FlutterCommand {
|
|
LogsCommand() {
|
|
argParser.addFlag('clear',
|
|
negatable: false,
|
|
abbr: 'c',
|
|
help: 'Clear log history before reading from logs.',
|
|
);
|
|
}
|
|
|
|
@override
|
|
final String name = 'logs';
|
|
|
|
@override
|
|
final String description = 'Show log output for running Flutter apps.';
|
|
|
|
@override
|
|
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => const <DevelopmentArtifact>{};
|
|
|
|
Device device;
|
|
|
|
@override
|
|
Future<FlutterCommandResult> verifyThenRunCommand(String commandPath) async {
|
|
device = await findTargetDevice();
|
|
if (device == null) {
|
|
throwToolExit(null);
|
|
}
|
|
return super.verifyThenRunCommand(commandPath);
|
|
}
|
|
|
|
@override
|
|
Future<FlutterCommandResult> runCommand() async {
|
|
if (boolArg('clear')) {
|
|
device.clearLogs();
|
|
}
|
|
|
|
final DeviceLogReader logReader = device.getLogReader();
|
|
|
|
Cache.releaseLockEarly();
|
|
|
|
printStatus('Showing $logReader logs:');
|
|
|
|
final Completer<int> exitCompleter = Completer<int>();
|
|
|
|
// Start reading.
|
|
final StreamSubscription<String> subscription = logReader.logLines.listen(
|
|
(String message) => printStatus(message, wrap: false),
|
|
onDone: () {
|
|
exitCompleter.complete(0);
|
|
},
|
|
onError: (dynamic error) {
|
|
exitCompleter.complete(error is int ? error : 1);
|
|
},
|
|
);
|
|
|
|
// When terminating, close down the log reader.
|
|
ProcessSignal.SIGINT.watch().listen((ProcessSignal signal) {
|
|
subscription.cancel();
|
|
printStatus('');
|
|
exitCompleter.complete(0);
|
|
});
|
|
ProcessSignal.SIGTERM.watch().listen((ProcessSignal signal) {
|
|
subscription.cancel();
|
|
exitCompleter.complete(0);
|
|
});
|
|
|
|
// Wait for the log reader to be finished.
|
|
final int result = await exitCompleter.future;
|
|
await subscription.cancel();
|
|
if (result != 0) {
|
|
throwToolExit('Error listening to $logReader logs.');
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|