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.stackTrace == null) {
    if (methodCount > 0) {
      stackTraceStr = formatStackTrace(StackTrace.current, methodCount);
    }
  } else if (errorMethodCount > 0) {
    stackTraceStr = formatStackTrace(event.stackTrace, errorMethodCount);
  }

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

  String? timeStr;
  if (printTime) {
    timeStr = getTime(event.time);
  }

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