diff --git a/packages/flutter_tools/lib/src/base/logger.dart b/packages/flutter_tools/lib/src/base/logger.dart index b43189e0c85..cefa0004f74 100644 --- a/packages/flutter_tools/lib/src/base/logger.dart +++ b/packages/flutter_tools/lib/src/base/logger.dart @@ -3,7 +3,7 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:convert' show ASCII; +import 'dart:convert' show ASCII, LineSplitter; import 'package:stack_trace/stack_trace.dart'; @@ -29,7 +29,10 @@ abstract class Logger { /// Display normal output of the command. This should be used for things like /// progress messages, success messages, or just normal command output. - void printStatus(String message, { bool emphasis: false, bool newline: true, String ansiAlternative }); + void printStatus( + String message, + { bool emphasis: false, bool newline: true, String ansiAlternative, int indent } + ); /// Use this for verbose tracing output. Users can turn this output on in order /// to help diagnose issues with the toolchain or with their setup. @@ -66,13 +69,18 @@ class StdoutLogger extends Logger { } @override - void printStatus(String message, { bool emphasis: false, bool newline: true, String ansiAlternative }) { + void printStatus( + String message, + { bool emphasis: false, bool newline: true, String ansiAlternative, int indent } + ) { _status?.cancel(); _status = null; if (terminal.supportsColor && ansiAlternative != null) message = ansiAlternative; if (emphasis) message = terminal.bolden(message); + if (indent != null && indent > 0) + message = LineSplitter.split(message).map((String line) => ' ' * indent + line).join('\n'); if (newline) message = '$message\n'; stdout.write(message); @@ -114,7 +122,10 @@ class BufferLogger extends Logger { void printError(String message, [StackTrace stackTrace]) => _error.writeln(message); @override - void printStatus(String message, { bool emphasis: false, bool newline: true, String ansiAlternative }) { + void printStatus( + String message, + { bool emphasis: false, bool newline: true, String ansiAlternative, int indent } + ) { if (newline) _status.writeln(message); else @@ -147,7 +158,10 @@ class VerboseLogger extends Logger { } @override - void printStatus(String message, { bool emphasis: false, bool newline: true, String ansiAlternative }) { + void printStatus( + String message, + { bool emphasis: false, bool newline: true, String ansiAlternative, int indent } + ) { _emit(_LogType.status, message); } diff --git a/packages/flutter_tools/lib/src/commands/daemon.dart b/packages/flutter_tools/lib/src/commands/daemon.dart index d822d188061..8e1111d4ea3 100644 --- a/packages/flutter_tools/lib/src/commands/daemon.dart +++ b/packages/flutter_tools/lib/src/commands/daemon.dart @@ -680,7 +680,10 @@ class NotifyingLogger extends Logger { } @override - void printStatus(String message, { bool emphasis: false, bool newline: true, String ansiAlternative }) { + void printStatus( + String message, + { bool emphasis: false, bool newline: true, String ansiAlternative, int indent } + ) { _messageController.add(new LogMessage('status', message)); } @@ -762,7 +765,10 @@ class _AppRunLogger extends Logger { } @override - void printStatus(String message, { bool emphasis: false, bool newline: true, String ansiAlternative }) { + void printStatus( + String message, + { bool emphasis: false, bool newline: true, String ansiAlternative, int indent } + ) { if (logToStdout) { print(message); } else { diff --git a/packages/flutter_tools/lib/src/globals.dart b/packages/flutter_tools/lib/src/globals.dart index 1ca818babfa..f177ebb402d 100644 --- a/packages/flutter_tools/lib/src/globals.dart +++ b/packages/flutter_tools/lib/src/globals.dart @@ -26,8 +26,19 @@ void printError(String message, [StackTrace stackTrace]) => logger.printError(me /// /// If `ansiAlternative` is provided, and the terminal supports color, that /// string will be printed instead of the message. -void printStatus(String message, { bool emphasis: false, bool newline: true, String ansiAlternative }) { - logger.printStatus(message, emphasis: emphasis, newline: newline, ansiAlternative: ansiAlternative); +/// +/// If `indent` is provided, each line of the message will be prepended by the specified number of +/// whitespaces. +void printStatus( + String message, + { bool emphasis: false, bool newline: true, String ansiAlternative, int indent }) { + logger.printStatus( + message, + emphasis: emphasis, + newline: newline, + ansiAlternative: ansiAlternative, + indent: indent + ); } /// Use this for verbose tracing output. Users can turn this output on in order diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index 2129afbc559..f2a85acfa67 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -166,10 +166,15 @@ Future buildXcodeProject({ ); if (result.exitCode != 0) { - if (result.stderr.isNotEmpty) - printStatus(result.stderr); - if (result.stdout.isNotEmpty) - printStatus(result.stdout); + printStatus('Failed to build iOS app'); + if (result.stderr.isNotEmpty) { + printStatus('Error output from Xcode build:\n↳'); + printStatus(result.stderr, indent: 4); + } + if (result.stdout.isNotEmpty) { + printStatus('Xcode\'s output:\n↳'); + printStatus(result.stdout, indent: 4); + } return new XcodeBuildResult( success: false, stdout: result.stdout,