output method

void output(
  1. String body, {
  2. String head = '',
  3. String tail = '',
  4. required String tag,
  5. required LogCaller caller,
})

colorful print

Implementation

void output(String body, {
  String head = '', String tail = '',
  required String tag, required LogCaller caller,
}) {
  int size = body.length;
  if (0 < limitLength && limitLength < size) {
    body = '${body.substring(0, limitLength - 4)} ...';
    size = limitLength;
  }
  String x;
  // print chunks
  int start = 0, end = chunkLength;
  for (; end < size; start = end, end += chunkLength) {
    x = head + body.substring(start, end) + tail + carriageReturn;
    println(x, tag: tag, caller: caller);
  }
  if (start > 0) {
    // print last chunk
    x = head + body.substring(start) + tail;
  } else {
    // too short, print the whole message
    x = head + body + tail;
  }
  println(x, tag: tag, caller: caller);
}