log method

  1. @override
void log(
  1. LogLevel level,
  2. Object? referer,
  3. String message, [
  4. dynamic error,
  5. StackTrace? stackTrace,
])
override

publish a log message

Implementation

@override
void log(level, referer, message, [error, stackTrace]) {
  if (level.index < minLevel.index) return;

  final msg = [
    level.name.toString().toUpperCase().add(":").padRight(10),
    (referer?.runtimeType.toString().add(":") ?? "").padRight(18),
    _multiLinePadded(_limited(message, maxWidth - 31), 29),
    if (error != null)
      _multiLinePadded(
          "\n" + _ansiU("ERROR:") + " " + _multiLinePadded("$error", 8), 29),
    if (stackTrace != null)
      level.index >= traceMinLevel.index
          ? "\n".padRight(11) + _multiLinePadded(stackTrace.toString(), 11)
          : "\n".padRight(29) + _ansiU("TRACE:") + " [suppressed]"
  ].join("");
  // ignore: avoid_print
  print(level.ansify(msg));
}