logRun<R> static method

R logRun<R>(
  1. R body(), {
  2. bool canPrint = true,
  3. Map<Object, Object>? zoneValues,
})

Implementation

static R logRun<R>(R Function() body,
    {bool canPrint = true, Map<Object, Object>? zoneValues}) {
  var lastPrint = '';
  var count = 1;

  return runZoned(body,
      zoneSpecification: ZoneSpecification(print: (s, d, z, line) {
    if (!canPrint) return;
    if (!debugMode) {
      d.print(z, line);
      return;
    }
    if (lastPrint != line) {
      d.print(z, line);
      lastPrint = line;
      count = 1;
      return;
    } else {
      if (line.length > 24) {
        count++;
        final func = line.substring(0, 24);
        final message = line.substring(24);
        d.print(z, '$func$count>$message');
        return;
      }
      d.print(z, line);
    }
  }), zoneValues: zoneValues);
}