Chromium Code Reviews| 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 0b93b3f3df26cee40c5b536b0bb67f05d22ec3c5..2cb537a032ab0f9ef5f8d2154556412ccca784bc 100644 |
| --- a/sdk/lib/_internal/pub/lib/src/log.dart |
| +++ b/sdk/lib/_internal/pub/lib/src/log.dart |
| @@ -37,8 +37,8 @@ const _MAX_TRANSCRIPT = 10000; |
| /// [recordTranscript()] is called. |
| Transcript<Entry> _transcript; |
| -/// The currently-running progress indicator or `null` if there is none. |
| -Progress _progress; |
| +/// The currently-running progress indicators. |
| +final _progresses = new Set<Progress>(); |
| final _cyan = getSpecial('\u001b[36m'); |
| final _green = getSpecial('\u001b[32m'); |
| @@ -222,29 +222,27 @@ void dumpTranscript() { |
| } |
| /// Prints [message] then displays an updated elapsed time until the future |
| -/// returned by [callback] completes. If anything else is logged during this |
| -/// (include another call to [progress]) that cancels the progress. |
| -Future progress(String message, Future callback()) { |
| +/// returned by [callback] completes. |
| +/// |
| +/// If anything else is logged during this (include another call to [progress]) |
|
Bob Nystrom
2014/06/05 20:18:16
"include" -> "including"
nweiz
2014/06/05 21:58:18
Done.
nweiz
2014/06/05 21:58:19
Done.
|
| +/// that cancels the progress animation, although the total time will still be |
| +/// printed once it finishes. If [fine] is passed, the progress information will |
| +/// only be visible at [Level.FINE]. |
| +Future progress(String message, Future callback(), {bool fine: false}) { |
|
Bob Nystrom
2014/06/05 20:18:16
Instead of a bool for fine, how about just taking
nweiz
2014/06/05 21:58:18
That's how I started doing it, but properly suppor
|
| _stopProgress(); |
| - _progress = new Progress(message); |
| + var progress = new Progress(message, fine: fine);; |
| + _progresses.add(progress); |
| return callback().whenComplete(() { |
| - var message = _stopProgress(); |
| - |
| - // Add the progress message to the transcript. |
| - if (_transcript != null && message != null) { |
| - _transcript.add(new Entry(Level.MESSAGE, [message])); |
| - } |
| + progress.stop(); |
| + _progresses.remove(progress); |
| }); |
| } |
| -/// Stops the running progress indicator, if currently running. |
| -/// |
| -/// Returns the final progress message, if any, otherwise `null`. |
| -String _stopProgress() { |
| - if (_progress == null) return null; |
| - var message = _progress.stop(); |
| - _progress = null; |
| - return message; |
| +/// Stops animating the running progress indicator, if currently running. |
| +void _stopProgress() { |
| + for (var progress in _progresses) { |
| + progress.stopAnimating(); |
| + } |
| } |
| /// Wraps [text] in the ANSI escape codes to make it bold when on a platform |
| @@ -333,6 +331,9 @@ void showAll() { |
| _loggers[Level.FINE] = _logToStderrWithLabel; |
| } |
| +/// Returns whether or not logs at [level] will be printed. |
| +bool isLevelVisible(Level level) => _loggers[level] != null; |
| + |
| /// Log function that prints the message to stdout. |
| void _logToStdout(Entry entry) { |
| _logToStream(stdout, entry, showLabel: false); |