add identifiers to progress messages (#6868)
This commit is contained in:
parent
f496ad055a
commit
15ea399fdd
@ -33,7 +33,10 @@ abstract class Logger {
|
|||||||
void printTrace(String message);
|
void printTrace(String message);
|
||||||
|
|
||||||
/// Start an indeterminate progress display.
|
/// 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 {
|
class Status {
|
||||||
@ -76,7 +79,7 @@ class StdoutLogger extends Logger {
|
|||||||
void printTrace(String message) { }
|
void printTrace(String message) { }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Status startProgress(String message) {
|
Status startProgress(String message, { String progressId }) {
|
||||||
if (_status != null) {
|
if (_status != null) {
|
||||||
// Ignore nested progresses; return a no-op status object.
|
// Ignore nested progresses; return a no-op status object.
|
||||||
return new Status();
|
return new Status();
|
||||||
@ -119,7 +122,7 @@ class BufferLogger extends Logger {
|
|||||||
void printTrace(String message) => _trace.writeln(message);
|
void printTrace(String message) => _trace.writeln(message);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Status startProgress(String message) {
|
Status startProgress(String message, { String progressId }) {
|
||||||
printStatus(message);
|
printStatus(message);
|
||||||
return new Status();
|
return new Status();
|
||||||
}
|
}
|
||||||
@ -151,7 +154,7 @@ class VerboseLogger extends Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Status startProgress(String message) {
|
Status startProgress(String message, { String progressId }) {
|
||||||
printStatus(message);
|
printStatus(message);
|
||||||
return new Status();
|
return new Status();
|
||||||
}
|
}
|
||||||
|
@ -637,7 +637,7 @@ class NotifyingLogger extends Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Status startProgress(String message) {
|
Status startProgress(String message, { String progressId }) {
|
||||||
printStatus(message);
|
printStatus(message);
|
||||||
return new Status();
|
return new Status();
|
||||||
}
|
}
|
||||||
@ -711,7 +711,7 @@ class _AppRunLogger extends Logger {
|
|||||||
Status _status;
|
Status _status;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Status startProgress(String message) {
|
Status startProgress(String message, { String progressId }) {
|
||||||
// Ignore nested progresses; return a no-op status object.
|
// Ignore nested progresses; return a no-op status object.
|
||||||
if (_status != null)
|
if (_status != null)
|
||||||
return new Status();
|
return new Status();
|
||||||
@ -720,10 +720,11 @@ class _AppRunLogger extends Logger {
|
|||||||
|
|
||||||
_sendProgressEvent(<String, dynamic>{
|
_sendProgressEvent(<String, dynamic>{
|
||||||
'id': id.toString(),
|
'id': id.toString(),
|
||||||
|
'progressId': progressId,
|
||||||
'message': message,
|
'message': message,
|
||||||
});
|
});
|
||||||
|
|
||||||
_status = new _AppLoggerStatus(this, id);
|
_status = new _AppLoggerStatus(this, id, progressId);
|
||||||
return _status;
|
return _status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -747,10 +748,11 @@ class _AppRunLogger extends Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _AppLoggerStatus implements Status {
|
class _AppLoggerStatus implements Status {
|
||||||
_AppLoggerStatus(this.logger, this.id);
|
_AppLoggerStatus(this.logger, this.id, this.progressId);
|
||||||
|
|
||||||
final _AppRunLogger logger;
|
final _AppRunLogger logger;
|
||||||
final int id;
|
final int id;
|
||||||
|
final String progressId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void stop({ bool showElapsedTime: true }) {
|
void stop({ bool showElapsedTime: true }) {
|
||||||
@ -767,6 +769,7 @@ class _AppLoggerStatus implements Status {
|
|||||||
void _sendFinished() {
|
void _sendFinished() {
|
||||||
logger._sendProgressEvent(<String, dynamic>{
|
logger._sendProgressEvent(<String, dynamic>{
|
||||||
'id': id.toString(),
|
'id': id.toString(),
|
||||||
|
'progressId': progressId,
|
||||||
'finished': true
|
'finished': true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -468,7 +468,7 @@ class HotRunner extends ResidentRunner {
|
|||||||
@override
|
@override
|
||||||
Future<OperationResult> restart({ bool fullRestart: false, bool pauseAfterRestart: false }) async {
|
Future<OperationResult> restart({ bool fullRestart: false, bool pauseAfterRestart: false }) async {
|
||||||
if (fullRestart) {
|
if (fullRestart) {
|
||||||
Status status = logger.startProgress('Performing full restart...');
|
Status status = logger.startProgress('Performing full restart...', progressId: 'hot.restart');
|
||||||
try {
|
try {
|
||||||
await _restartFromSources();
|
await _restartFromSources();
|
||||||
status.stop();
|
status.stop();
|
||||||
@ -479,7 +479,7 @@ class HotRunner extends ResidentRunner {
|
|||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Status status = logger.startProgress('Performing hot reload...');
|
Status status = logger.startProgress('Performing hot reload...', progressId: 'hot.reload');
|
||||||
try {
|
try {
|
||||||
OperationResult result = await _reloadSources(pause: pauseAfterRestart);
|
OperationResult result = await _reloadSources(pause: pauseAfterRestart);
|
||||||
status.stop();
|
status.stop();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user