Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Unified Diff: sdk/lib/_internal/pub/lib/src/log.dart

Issue 26572010: Improve barback/pub logging. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add missing file. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
« sdk/lib/_internal/pub/lib/src/dart.dart ('K') | « sdk/lib/_internal/pub/lib/src/dart.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698