logTimedAsync<T> function
Logs an asynchronous action
with description
before and after.
Returns a future that completes after the action and logging finishes.
Implementation
Future<T> logTimedAsync<T>(
Logger logger,
String description,
Future<T> Function() action, {
Level level = Level.INFO,
}) async {
final watch = Stopwatch()..start();
logger.log(level, '$description...');
final result = await action();
watch.stop();
final time = '${humanReadable(watch.elapsed)}$_logSuffix';
logger.log(level, '$description completed, took $time');
return result;
}