Add logger indent option and indent nested xcode command outputs (#7867)
* Add indent option to logger and indent non-flutter nested output * Add a missed override * Formatting
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert' show ASCII;
|
import 'dart:convert' show ASCII, LineSplitter;
|
||||||
|
|
||||||
import 'package:stack_trace/stack_trace.dart';
|
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
|
/// Display normal output of the command. This should be used for things like
|
||||||
/// progress messages, success messages, or just normal command output.
|
/// 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
|
/// 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.
|
/// to help diagnose issues with the toolchain or with their setup.
|
||||||
@@ -66,13 +69,18 @@ class StdoutLogger extends Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@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?.cancel();
|
||||||
_status = null;
|
_status = null;
|
||||||
if (terminal.supportsColor && ansiAlternative != null)
|
if (terminal.supportsColor && ansiAlternative != null)
|
||||||
message = ansiAlternative;
|
message = ansiAlternative;
|
||||||
if (emphasis)
|
if (emphasis)
|
||||||
message = terminal.bolden(message);
|
message = terminal.bolden(message);
|
||||||
|
if (indent != null && indent > 0)
|
||||||
|
message = LineSplitter.split(message).map((String line) => ' ' * indent + line).join('\n');
|
||||||
if (newline)
|
if (newline)
|
||||||
message = '$message\n';
|
message = '$message\n';
|
||||||
stdout.write(message);
|
stdout.write(message);
|
||||||
@@ -114,7 +122,10 @@ class BufferLogger extends Logger {
|
|||||||
void printError(String message, [StackTrace stackTrace]) => _error.writeln(message);
|
void printError(String message, [StackTrace stackTrace]) => _error.writeln(message);
|
||||||
|
|
||||||
@override
|
@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)
|
if (newline)
|
||||||
_status.writeln(message);
|
_status.writeln(message);
|
||||||
else
|
else
|
||||||
@@ -147,7 +158,10 @@ class VerboseLogger extends Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@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);
|
_emit(_LogType.status, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -680,7 +680,10 @@ class NotifyingLogger extends Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@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));
|
_messageController.add(new LogMessage('status', message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -762,7 +765,10 @@ class _AppRunLogger extends Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@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) {
|
if (logToStdout) {
|
||||||
print(message);
|
print(message);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -26,8 +26,19 @@ void printError(String message, [StackTrace stackTrace]) => logger.printError(me
|
|||||||
///
|
///
|
||||||
/// If `ansiAlternative` is provided, and the terminal supports color, that
|
/// If `ansiAlternative` is provided, and the terminal supports color, that
|
||||||
/// string will be printed instead of the message.
|
/// 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
|
/// Use this for verbose tracing output. Users can turn this output on in order
|
||||||
|
|||||||
@@ -166,10 +166,15 @@ Future<XcodeBuildResult> buildXcodeProject({
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (result.exitCode != 0) {
|
if (result.exitCode != 0) {
|
||||||
if (result.stderr.isNotEmpty)
|
printStatus('Failed to build iOS app');
|
||||||
printStatus(result.stderr);
|
if (result.stderr.isNotEmpty) {
|
||||||
if (result.stdout.isNotEmpty)
|
printStatus('Error output from Xcode build:\n↳');
|
||||||
printStatus(result.stdout);
|
printStatus(result.stderr, indent: 4);
|
||||||
|
}
|
||||||
|
if (result.stdout.isNotEmpty) {
|
||||||
|
printStatus('Xcode\'s output:\n↳');
|
||||||
|
printStatus(result.stdout, indent: 4);
|
||||||
|
}
|
||||||
return new XcodeBuildResult(
|
return new XcodeBuildResult(
|
||||||
success: false,
|
success: false,
|
||||||
stdout: result.stdout,
|
stdout: result.stdout,
|
||||||
|
|||||||
Reference in New Issue
Block a user