Let printError be able to print bold also (#9714)

* Let printError print bold as well

* review notes
This commit is contained in:
xster 2017-05-02 22:20:14 -07:00 committed by GitHub
parent 31000ef77e
commit 87d0010adb
5 changed files with 19 additions and 10 deletions

View File

@ -160,7 +160,7 @@ class AndroidDevice extends Device {
return true;
printError('The ADB at "${getAdbPath(androidSdk)}" is too old; please install version 1.0.32 or later.');
} catch (error, trace) {
printError('Error running ADB: $error', trace);
printError('Error running ADB: $error', stackTrace: trace);
}
return false;

View File

@ -155,7 +155,7 @@ abstract class IOSApp extends ApplicationPackage {
final Directory payloadDir = fs.directory(fs.path.join(tempDir.path, 'Payload'));
bundleDir = payloadDir.listSync().singleWhere(_isBundleDirectory);
} on StateError catch (e, stackTrace) {
printError('Invalid prebuilt iOS binary: ${e.toString()}', stackTrace);
printError('Invalid prebuilt iOS binary: ${e.toString()}', stackTrace: stackTrace);
return null;
}

View File

@ -25,7 +25,7 @@ abstract class Logger {
/// Display an error level message to the user. Commands should use this if they
/// fail in some way.
void printError(String message, [StackTrace stackTrace]);
void printError(String message, { StackTrace stackTrace, bool emphasis: false });
/// Display normal output of the command. This should be used for things like
/// progress messages, success messages, or just normal command output.
@ -60,10 +60,12 @@ class StdoutLogger extends Logger {
bool get isVerbose => false;
@override
void printError(String message, [StackTrace stackTrace]) {
void printError(String message, { StackTrace stackTrace, bool emphasis: false }) {
_status?.cancel();
_status = null;
if (emphasis)
message = terminal.bolden(message);
stderr.writeln(message);
if (stackTrace != null)
stderr.writeln(stackTrace.toString());
@ -144,7 +146,10 @@ class BufferLogger extends Logger {
String get traceText => _trace.toString();
@override
void printError(String message, [StackTrace stackTrace]) => _error.writeln(message);
void printError(String message, { StackTrace stackTrace, bool emphasis: false }) {
_error.writeln(message);
}
@override
void printStatus(
@ -185,7 +190,7 @@ class VerboseLogger extends Logger {
bool get isVerbose => true;
@override
void printError(String message, [StackTrace stackTrace]) {
void printError(String message, { StackTrace stackTrace, bool emphasis: false }) {
_emit(_LogType.error, message, stackTrace);
}

View File

@ -66,7 +66,7 @@ class DaemonCommand extends FlutterCommand {
}
dynamic _handleError(dynamic error, StackTrace stackTrace) {
printError('Error from flutter daemon: $error', stackTrace);
printError('Error from flutter daemon: $error', stackTrace: stackTrace);
return null;
}
}
@ -690,7 +690,7 @@ class NotifyingLogger extends Logger {
Stream<LogMessage> get onMessage => _messageController.stream;
@override
void printError(String message, [StackTrace stackTrace]) {
void printError(String message, { StackTrace stackTrace, bool emphasis: false }) {
_messageController.add(new LogMessage('error', message, stackTrace));
}
@ -757,7 +757,7 @@ class _AppRunLogger extends Logger {
int _nextProgressId = 0;
@override
void printError(String message, [StackTrace stackTrace]) {
void printError(String message, { StackTrace stackTrace, bool emphasis: false }) {
if (logToStdout) {
stderr.writeln(message);
if (stackTrace != null)

View File

@ -15,7 +15,11 @@ Artifacts get artifacts => Artifacts.instance;
/// Display an error level message to the user. Commands should use this if they
/// fail in some way.
void printError(String message, [StackTrace stackTrace]) => logger.printError(message, stackTrace);
///
/// Set `emphasis` to true to make the output bold if it's supported.
void printError(String message, { StackTrace stackTrace, bool emphasis: false }) {
logger.printError(message, stackTrace: stackTrace, emphasis: emphasis);
}
/// Display normal output of the command. This should be used for things like
/// progress messages, success messages, or just normal command output.