runWithLogger<T> function

void runWithLogger<T>(
  1. RefinedLogger logger,
  2. T callback()
)

Runs callback with the given logger instance.

This is Zone-scoped, so asynchronous callbacks spawned within callback will also use the new value for logger.

This is useful for testing purposes, where you can pass a mock logger to the callback.

Implementation

void runWithLogger<T>(
  RefinedLogger logger,
  T Function() callback,
) {
  runZoned(
    callback,
    zoneValues: <Object?, Object?>{_loggerKey: logger},
  );
}