printLog method

void printLog(
  1. String logLine, {
  2. String? level,
})

Method to overload printing to output stream the formatted logLine Adds handing of time

Implementation

void printLog(String logLine, {String? level}) {
  var printableLine = logLine;
  if (printTimeType == timeElapsedType) {
    final timeElapsed = _elapsedTimeStopwatch.elapsed.toString();
    printableLine = '$timeElapsed\t$logLine';
  } else {
    final date = DateTime.now().toIso8601String();
    printableLine = '$date\t$logLine';
  }
  final colorizeTransform = (level != null) ? colorizeMap[level] : null;
  if (colorizeTransform != null) {
    // ignore: avoid_print
    print(colorizeTransform.wrap(printableLine));
  } else {
    // ignore: avoid_print
    print(printableLine);
  }
}