mirror of
https://github.com/flutter/packages.git
synced 2025-07-01 15:23:25 +08:00
Flush logger IOSink. (#229)
If we are writing to a file sometimes the content is incomplete because not all the output has been written to the file. Bug: https://github.com/flutter/flutter/issues/67942
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
# CHANGELOG
|
||||
|
||||
## version:0.0.27
|
||||
|
||||
- Flush the content of iosink when writing output to a file.
|
||||
|
||||
## version:0.0.26
|
||||
|
||||
- Replace amberctl with pkgctl.
|
||||
|
@ -108,6 +108,12 @@ class PrintLogger implements Logger {
|
||||
out.writeln('$message');
|
||||
}
|
||||
}
|
||||
|
||||
/// Flushes the IOSink to ensure all the data is written. This is specially
|
||||
/// useful when writing to a file.
|
||||
Future<void> flush() async {
|
||||
await out.flush();
|
||||
}
|
||||
}
|
||||
|
||||
/// Transforms a [message] with [level] to a string that contains the DateTime,
|
||||
|
@ -146,6 +146,9 @@ class SshClient {
|
||||
stdoutSubscription.asFuture<void>(),
|
||||
stderrSubscription.asFuture<void>(),
|
||||
]);
|
||||
|
||||
await logger.flush();
|
||||
|
||||
// The streams as futures have already completed, so waiting for the
|
||||
// potentially async stream cancellation to complete likely has no benefit.
|
||||
stdoutSubscription.cancel();
|
||||
|
@ -18,7 +18,7 @@ void main() {
|
||||
logger.info('cdf');
|
||||
logger.warning('gh');
|
||||
logger.error('jk');
|
||||
await data.flush();
|
||||
await logger.flush();
|
||||
final String content = fs.file('log.txt').readAsStringSync();
|
||||
expect(content, contains('ERROR jk'));
|
||||
expect(content, contains('INFO cdf'));
|
||||
@ -48,7 +48,7 @@ void main() {
|
||||
logger.info('cdf');
|
||||
logger.warning('gh');
|
||||
logger.error('jk');
|
||||
await data.flush();
|
||||
await logger.flush();
|
||||
final String content = fs.file('log.txt').readAsStringSync();
|
||||
expect(content, contains('ERROR jk'));
|
||||
expect(content, contains('INFO cdf'));
|
||||
|
Reference in New Issue
Block a user