Index: sdk/lib/_internal/pub/lib/src/log.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/log.dart b/sdk/lib/_internal/pub/lib/src/log.dart |
index 2d61143e0a430512065c599d6c5d213ff4ec24f0..3ad49089e7a031dca8ec742f53a0931c64ed7c29 100644 |
--- a/sdk/lib/_internal/pub/lib/src/log.dart |
+++ b/sdk/lib/_internal/pub/lib/src/log.dart |
@@ -25,6 +25,11 @@ Timer _progressTimer; |
/// progress is done, a single entry will be added to the log for it. |
String _progressMessage; |
+final _green = getSpecial('\u001b[32m'); |
+final _red = getSpecial('\u001b[31m'); |
+final _yellow = getSpecial('\u001b[33m'); |
+final _none = getSpecial('\u001b[0m'); |
+ |
/// An enum type for defining the different logging levels. By default, [ERROR] |
/// and [WARNING] messages are printed to sterr. [MESSAGE] messages are printed |
/// to stdout, and others are ignored. |
@@ -202,6 +207,18 @@ Future progress(String message, Future callback()) { |
return callback().whenComplete(_stopProgress); |
} |
+/// Wraps [text] in the ANSI escape codes to color it green when on a platform |
+/// that supports that. |
+String green(text) => "$_green$text$_none"; |
+ |
+/// Wraps [text] in the ANSI escape codes to color it red when on a platform |
+/// that supports that. |
+String red(text) => "$_red$text$_none"; |
+ |
+/// Wraps [text] in the ANSI escape codes to color it yellow when on a platform |
+/// that supports that. |
+String yellow(text) => "$_yellow$text$_none"; |
+ |
/// Stops the running progress indicator, if currently running. |
_stopProgress() { |
if (_progressTimer == null) return; |