log method

  1. @override
List<String> log(
  1. LogEvent event
)
override

Is called every time a new LogEvent is sent and handles printing or storing the message.

Implementation

@override
List<String> log(LogEvent event) {
  var messageStr = stringifyMessage(event.message);

  String? stackTraceStr;
  if (event.error != null) {
    if ((errorMethodCount == null || errorMethodCount! > 0)) {
      stackTraceStr = formatStackTrace(
        event.stackTrace ?? StackTrace.current,
        errorMethodCount,
      );
    }
  } else if (methodCount == null || methodCount! > 0) {
    stackTraceStr = formatStackTrace(
      event.stackTrace ?? StackTrace.current,
      methodCount,
    );
  }

  var errorStr = event.error?.toString();

  String? timeStr;
  // Keep backwards-compatibility to `printTime` check
  // ignore: deprecated_member_use_from_same_package
  if (printTime) {
    timeStr = getTime(event.time);
  }

  return _formatAndPrint(
    event.level,
    messageStr,
    timeStr,
    errorStr,
    stackTraceStr,
  );
}