Commit 53dd5dbd authored by Devon Carew's avatar Devon Carew Committed by GitHub

print more logging info when tracing (#5419)

parent a8369413
...@@ -22,7 +22,7 @@ Future<Process> runCommand(List<String> cmd, { ...@@ -22,7 +22,7 @@ Future<Process> runCommand(List<String> cmd, {
String workingDirectory, String workingDirectory,
bool allowReentrantFlutter: false bool allowReentrantFlutter: false
}) async { }) async {
printTrace(cmd.join(' ')); _traceCommand(cmd, workingDirectory: workingDirectory);
String executable = cmd[0]; String executable = cmd[0];
List<String> arguments = cmd.length > 1 ? cmd.sublist(1) : <String>[]; List<String> arguments = cmd.length > 1 ? cmd.sublist(1) : <String>[];
Process process = await Process.start( Process process = await Process.start(
...@@ -86,7 +86,7 @@ Future<Null> runAndKill(List<String> cmd, Duration timeout) { ...@@ -86,7 +86,7 @@ Future<Null> runAndKill(List<String> cmd, Duration timeout) {
} }
Future<Process> runDetached(List<String> cmd) { Future<Process> runDetached(List<String> cmd) {
printTrace(cmd.join(' ')); _traceCommand(cmd);
Future<Process> proc = Process.start( Future<Process> proc = Process.start(
cmd[0], cmd.getRange(1, cmd.length).toList(), cmd[0], cmd.getRange(1, cmd.length).toList(),
mode: ProcessStartMode.DETACHED mode: ProcessStartMode.DETACHED
...@@ -98,7 +98,7 @@ Future<RunResult> runAsync(List<String> cmd, { ...@@ -98,7 +98,7 @@ Future<RunResult> runAsync(List<String> cmd, {
String workingDirectory, String workingDirectory,
bool allowReentrantFlutter: false bool allowReentrantFlutter: false
}) async { }) async {
printTrace(cmd.join(' ')); _traceCommand(cmd, workingDirectory: workingDirectory);
ProcessResult results = await Process.run( ProcessResult results = await Process.run(
cmd[0], cmd[0],
cmd.getRange(1, cmd.length).toList(), cmd.getRange(1, cmd.length).toList(),
...@@ -111,7 +111,7 @@ Future<RunResult> runAsync(List<String> cmd, { ...@@ -111,7 +111,7 @@ Future<RunResult> runAsync(List<String> cmd, {
} }
bool exitsHappy(List<String> cli) { bool exitsHappy(List<String> cli) {
printTrace(cli.join(' ')); _traceCommand(cli);
try { try {
return Process.runSync(cli.first, cli.sublist(1)).exitCode == 0; return Process.runSync(cli.first, cli.sublist(1)).exitCode == 0;
} catch (error) { } catch (error) {
...@@ -124,16 +124,14 @@ bool exitsHappy(List<String> cli) { ...@@ -124,16 +124,14 @@ bool exitsHappy(List<String> cli) {
/// Throws an error if cmd exits with a non-zero value. /// Throws an error if cmd exits with a non-zero value.
String runCheckedSync(List<String> cmd, { String runCheckedSync(List<String> cmd, {
String workingDirectory, String workingDirectory,
bool allowReentrantFlutter: false, bool allowReentrantFlutter: false
bool truncateCommand: false
}) { }) {
return _runWithLoggingSync( return _runWithLoggingSync(
cmd, cmd,
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
allowReentrantFlutter: allowReentrantFlutter, allowReentrantFlutter: allowReentrantFlutter,
checked: true, checked: true,
noisyErrors: true, noisyErrors: true
truncateCommand: truncateCommand
); );
} }
...@@ -149,17 +147,24 @@ String runSync(List<String> cmd, { ...@@ -149,17 +147,24 @@ String runSync(List<String> cmd, {
); );
} }
void _traceCommand(List<String> args, { String workingDirectory }) {
final int kMaxArgsLength = 1024;
String argsText = args.join(' ');
if (argsText.length > kMaxArgsLength)
argsText = argsText.substring(0, kMaxArgsLength) + '…';
if (workingDirectory == null)
printTrace(argsText);
else
printTrace("[$workingDirectory${Platform.pathSeparator}] $argsText");
}
String _runWithLoggingSync(List<String> cmd, { String _runWithLoggingSync(List<String> cmd, {
bool checked: false, bool checked: false,
bool noisyErrors: false, bool noisyErrors: false,
String workingDirectory, String workingDirectory,
bool allowReentrantFlutter: false, bool allowReentrantFlutter: false
bool truncateCommand: false
}) { }) {
String cmdText = cmd.join(' '); _traceCommand(cmd, workingDirectory: workingDirectory);
if (truncateCommand && cmdText.length > 160)
cmdText = cmdText.substring(0, 160) + '…';
printTrace(cmdText);
ProcessResult results = Process.runSync( ProcessResult results = Process.runSync(
cmd[0], cmd[0],
cmd.getRange(1, cmd.length).toList(), cmd.getRange(1, cmd.length).toList(),
......
...@@ -74,16 +74,14 @@ class _ZipToolBuilder extends ZipBuilder { ...@@ -74,16 +74,14 @@ class _ZipToolBuilder extends ZipBuilder {
if (_getCompressedNames().isNotEmpty) { if (_getCompressedNames().isNotEmpty) {
runCheckedSync( runCheckedSync(
<String>['zip', '-q', outFile.absolute.path]..addAll(_getCompressedNames()), <String>['zip', '-q', outFile.absolute.path]..addAll(_getCompressedNames()),
workingDirectory: zipBuildDir.path, workingDirectory: zipBuildDir.path
truncateCommand: true
); );
} }
if (_getStoredNames().isNotEmpty) { if (_getStoredNames().isNotEmpty) {
runCheckedSync( runCheckedSync(
<String>['zip', '-q', '-0', outFile.absolute.path]..addAll(_getStoredNames()), <String>['zip', '-q', '-0', outFile.absolute.path]..addAll(_getStoredNames()),
workingDirectory: zipBuildDir.path, workingDirectory: zipBuildDir.path
truncateCommand: true
); );
} }
} }
......
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