group<T> method

Future<T> group<T>(
  1. String name,
  2. Future<T> function()
)

All logs written while executing the function will be grouped together.

The group will be closed after it finishes, or in case an exception occurs.

Implementation

Future<T> group<T>(String name, Future<T> Function() function) async {
  startGroup(name);
  T result;
  try {
    result = await function();
  } finally {
    endGroup();
  }
  return result;
}