Commit 87d0010a authored by xster's avatar xster Committed by GitHub

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

* Let printError print bold as well

* review notes
parent 31000ef7
...@@ -160,7 +160,7 @@ class AndroidDevice extends Device { ...@@ -160,7 +160,7 @@ class AndroidDevice extends Device {
return true; return true;
printError('The ADB at "${getAdbPath(androidSdk)}" is too old; please install version 1.0.32 or later.'); printError('The ADB at "${getAdbPath(androidSdk)}" is too old; please install version 1.0.32 or later.');
} catch (error, trace) { } catch (error, trace) {
printError('Error running ADB: $error', trace); printError('Error running ADB: $error', stackTrace: trace);
} }
return false; return false;
......
...@@ -155,7 +155,7 @@ abstract class IOSApp extends ApplicationPackage { ...@@ -155,7 +155,7 @@ abstract class IOSApp extends ApplicationPackage {
final Directory payloadDir = fs.directory(fs.path.join(tempDir.path, 'Payload')); final Directory payloadDir = fs.directory(fs.path.join(tempDir.path, 'Payload'));
bundleDir = payloadDir.listSync().singleWhere(_isBundleDirectory); bundleDir = payloadDir.listSync().singleWhere(_isBundleDirectory);
} on StateError catch (e, stackTrace) { } on StateError catch (e, stackTrace) {
printError('Invalid prebuilt iOS binary: ${e.toString()}', stackTrace); printError('Invalid prebuilt iOS binary: ${e.toString()}', stackTrace: stackTrace);
return null; return null;
} }
......
...@@ -25,7 +25,7 @@ abstract class Logger { ...@@ -25,7 +25,7 @@ abstract class Logger {
/// Display an error level message to the user. Commands should use this if they /// Display an error level message to the user. Commands should use this if they
/// fail in some way. /// 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 /// 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.
...@@ -60,10 +60,12 @@ class StdoutLogger extends Logger { ...@@ -60,10 +60,12 @@ class StdoutLogger extends Logger {
bool get isVerbose => false; bool get isVerbose => false;
@override @override
void printError(String message, [StackTrace stackTrace]) { void printError(String message, { StackTrace stackTrace, bool emphasis: false }) {
_status?.cancel(); _status?.cancel();
_status = null; _status = null;
if (emphasis)
message = terminal.bolden(message);
stderr.writeln(message); stderr.writeln(message);
if (stackTrace != null) if (stackTrace != null)
stderr.writeln(stackTrace.toString()); stderr.writeln(stackTrace.toString());
...@@ -144,7 +146,10 @@ class BufferLogger extends Logger { ...@@ -144,7 +146,10 @@ class BufferLogger extends Logger {
String get traceText => _trace.toString(); String get traceText => _trace.toString();
@override @override
void printError(String message, [StackTrace stackTrace]) => _error.writeln(message); void printError(String message, { StackTrace stackTrace, bool emphasis: false }) {
_error.writeln(message);
}
@override @override
void printStatus( void printStatus(
...@@ -185,7 +190,7 @@ class VerboseLogger extends Logger { ...@@ -185,7 +190,7 @@ class VerboseLogger extends Logger {
bool get isVerbose => true; bool get isVerbose => true;
@override @override
void printError(String message, [StackTrace stackTrace]) { void printError(String message, { StackTrace stackTrace, bool emphasis: false }) {
_emit(_LogType.error, message, stackTrace); _emit(_LogType.error, message, stackTrace);
} }
......
...@@ -66,7 +66,7 @@ class DaemonCommand extends FlutterCommand { ...@@ -66,7 +66,7 @@ class DaemonCommand extends FlutterCommand {
} }
dynamic _handleError(dynamic error, StackTrace stackTrace) { dynamic _handleError(dynamic error, StackTrace stackTrace) {
printError('Error from flutter daemon: $error', stackTrace); printError('Error from flutter daemon: $error', stackTrace: stackTrace);
return null; return null;
} }
} }
...@@ -690,7 +690,7 @@ class NotifyingLogger extends Logger { ...@@ -690,7 +690,7 @@ class NotifyingLogger extends Logger {
Stream<LogMessage> get onMessage => _messageController.stream; Stream<LogMessage> get onMessage => _messageController.stream;
@override @override
void printError(String message, [StackTrace stackTrace]) { void printError(String message, { StackTrace stackTrace, bool emphasis: false }) {
_messageController.add(new LogMessage('error', message, stackTrace)); _messageController.add(new LogMessage('error', message, stackTrace));
} }
...@@ -757,7 +757,7 @@ class _AppRunLogger extends Logger { ...@@ -757,7 +757,7 @@ class _AppRunLogger extends Logger {
int _nextProgressId = 0; int _nextProgressId = 0;
@override @override
void printError(String message, [StackTrace stackTrace]) { void printError(String message, { StackTrace stackTrace, bool emphasis: false }) {
if (logToStdout) { if (logToStdout) {
stderr.writeln(message); stderr.writeln(message);
if (stackTrace != null) if (stackTrace != null)
......
...@@ -15,7 +15,11 @@ Artifacts get artifacts => Artifacts.instance; ...@@ -15,7 +15,11 @@ Artifacts get artifacts => Artifacts.instance;
/// Display an error level message to the user. Commands should use this if they /// Display an error level message to the user. Commands should use this if they
/// fail in some way. /// 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 /// 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.
......
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