configureLogger method

  1. @protected
void configureLogger()

Configures the root logger to provide information about log messages.

By default, this prints information out to stdout.

Implementation

@protected
void configureLogger() {
  _loggerSubscription = Logger.root.onRecord.listen((record) {
    _testPrint(
      '[${record.level.name}] @ ${Simulator.time}'
      ' | ${record.loggerName}: ${record.message}',
      record.level,
    );
    if (record.error != null) {
      _testPrint('> Error: ${record.error}', record.level);
    }
    if (record.stackTrace != null) {
      _testPrint('> Stack trace: \n${record.stackTrace}', record.level);
    }

    if (record.level >= killLevel) {
      failureDetected = true;

      _testPrint('Killing test due to detected failure.', record.level);

      Simulator.endSimulation();
    } else if (record.level >= failLevel) {
      if (!failureDetected) {
        _testPrint('Test failure detected, but continuing to run to end.',
            record.level);
      }
      failureDetected = true;
    }
  });
}