mirror of
https://github.com/flutter/flutter
synced 2024-10-13 03:32:55 +00:00
Add optional prefix to runCommandAndStreamOutput for logs commands.
This commit is contained in:
parent
5e11889160
commit
a6635489f5
|
@ -334,7 +334,7 @@ class AndroidDevice extends _Device {
|
|||
'-s',
|
||||
'sky',
|
||||
'chromium',
|
||||
]);
|
||||
], prefix: 'ANDROID: ');
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -14,15 +14,16 @@ final Logger _logging = new Logger('sky_tools.process');
|
|||
|
||||
/// This runs the command and streams stdout/stderr from the child process to
|
||||
/// this process' stdout/stderr.
|
||||
Future<int> runCommandAndStreamOutput(List<String> cmd) async {
|
||||
Future<int> runCommandAndStreamOutput(List<String> cmd,
|
||||
{String prefix: ''}) async {
|
||||
_logging.info(cmd.join(' '));
|
||||
Process proc =
|
||||
await Process.start(cmd[0], cmd.getRange(1, cmd.length).toList());
|
||||
proc.stdout.transform(UTF8.decoder).listen((data) {
|
||||
stdout.write(data);
|
||||
stdout.write('$prefix${data.trimRight().split('\n').join('\n$prefix')}\n');
|
||||
});
|
||||
proc.stderr.transform(UTF8.decoder).listen((data) {
|
||||
stderr.write(data);
|
||||
stderr.write('$prefix${data.trimRight().split('\n').join('\n$prefix')}\n');
|
||||
});
|
||||
return proc.exitCode;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue