anchor.diff:  /// will log a heartbeat message with the current elapsed time since [start] was
   /// originally invoked.
   class HeartbeatLogger {
  -  CancelableOperation _nextHeartbeat;
     StreamSubscription<LogRecord> _listener;
  -  Stopwatch _watch;
  +  Stopwatch _totalWatch;
  +  Stopwatch _intervalWatch;
  +  Timer _timer;
   
     /// The amount of time between heartbeats.
     final Duration waitDuration;
  
positive.code: 
  import 'dart:async';
  
  import 'package:async/async.dart';
  import 'package:logging/logging.dart';
  import 'package:millisecond/millisecond.dart' as ms;
  
  
negative.code: 
    /// Starts this heartbeat logger, must not already be started.
    void start() {
      if (_totalWatch != null ||
          _intervalWatch != null ||
          _listener != null ||
          _timer != null) {
        throw new StateError('HeartbeatLogger already started');
      }
      _totalWatch = new Stopwatch()..start();
      _intervalWatch = new Stopwatch()..start();
      _resetHeartbeat();
      _listener = Logger.root.onRecord.listen((_) => _resetHeartbeat());
      _timer = new Timer.periodic(
          const Duration(milliseconds: 100), _logIfDurationIsMet);
    }
  
    /// Stops this heartbeat logger, must already be started.
    void stop() {
      if (_totalWatch == null ||
          _intervalWatch == null ||
          _listener == null ||
          _timer == null) {
        throw new StateError('HeartbeatLogger was never started');
      }
      _totalWatch.stop();
      _totalWatch = null;
      _intervalWatch.stop();
      _intervalWatch = null;
      _listener.cancel();
      _listener = null;
      _timer.cancel();
      _timer = null;
    }
  
    /// Resets the current [_intervalWatch].
    void _resetHeartbeat() {
      _intervalWatch.reset();
    }
  
    /// Logs a heartbeat message if [_intervalWatch] has been running for
    /// [waitDuration] or more.
    void _logIfDurationIsMet(_) {
      if (_intervalWatch.elapsedMilliseconds < waitDuration.inMilliseconds) {
        return;
      }
  
      var formattedTime = ms.format(_totalWatch.elapsedMilliseconds, long: true);
      _logger.info('... still running ($formattedTime so far)');
      _resetHeartbeat();
    }
  }
  