Commit 15ea399f authored by Devon Carew's avatar Devon Carew Committed by GitHub

add identifiers to progress messages (#6868)

parent f496ad05
......@@ -33,7 +33,10 @@ abstract class Logger {
void printTrace(String message);
/// Start an indeterminate progress display.
Status startProgress(String message);
///
/// [message] is the message to display to the user; [progressId] provides an ID which can be
/// used to identify this type of progress (`hot.reload`, `hot.restart`, ...).
Status startProgress(String message, { String progressId });
}
class Status {
......@@ -76,7 +79,7 @@ class StdoutLogger extends Logger {
void printTrace(String message) { }
@override
Status startProgress(String message) {
Status startProgress(String message, { String progressId }) {
if (_status != null) {
// Ignore nested progresses; return a no-op status object.
return new Status();
......@@ -119,7 +122,7 @@ class BufferLogger extends Logger {
void printTrace(String message) => _trace.writeln(message);
@override
Status startProgress(String message) {
Status startProgress(String message, { String progressId }) {
printStatus(message);
return new Status();
}
......@@ -151,7 +154,7 @@ class VerboseLogger extends Logger {
}
@override
Status startProgress(String message) {
Status startProgress(String message, { String progressId }) {
printStatus(message);
return new Status();
}
......
......@@ -637,7 +637,7 @@ class NotifyingLogger extends Logger {
}
@override
Status startProgress(String message) {
Status startProgress(String message, { String progressId }) {
printStatus(message);
return new Status();
}
......@@ -711,7 +711,7 @@ class _AppRunLogger extends Logger {
Status _status;
@override
Status startProgress(String message) {
Status startProgress(String message, { String progressId }) {
// Ignore nested progresses; return a no-op status object.
if (_status != null)
return new Status();
......@@ -720,10 +720,11 @@ class _AppRunLogger extends Logger {
_sendProgressEvent(<String, dynamic>{
'id': id.toString(),
'progressId': progressId,
'message': message,
});
_status = new _AppLoggerStatus(this, id);
_status = new _AppLoggerStatus(this, id, progressId);
return _status;
}
......@@ -747,10 +748,11 @@ class _AppRunLogger extends Logger {
}
class _AppLoggerStatus implements Status {
_AppLoggerStatus(this.logger, this.id);
_AppLoggerStatus(this.logger, this.id, this.progressId);
final _AppRunLogger logger;
final int id;
final String progressId;
@override
void stop({ bool showElapsedTime: true }) {
......@@ -767,6 +769,7 @@ class _AppLoggerStatus implements Status {
void _sendFinished() {
logger._sendProgressEvent(<String, dynamic>{
'id': id.toString(),
'progressId': progressId,
'finished': true
});
}
......
......@@ -468,7 +468,7 @@ class HotRunner extends ResidentRunner {
@override
Future<OperationResult> restart({ bool fullRestart: false, bool pauseAfterRestart: false }) async {
if (fullRestart) {
Status status = logger.startProgress('Performing full restart...');
Status status = logger.startProgress('Performing full restart...', progressId: 'hot.restart');
try {
await _restartFromSources();
status.stop();
......@@ -479,7 +479,7 @@ class HotRunner extends ResidentRunner {
rethrow;
}
} else {
Status status = logger.startProgress('Performing hot reload...');
Status status = logger.startProgress('Performing hot reload...', progressId: 'hot.reload');
try {
OperationResult result = await _reloadSources(pause: pauseAfterRestart);
status.stop();
......
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