printLog<E> method

  1. @override
void printLog<E>(
  1. Level level,
  2. dynamic message, {
  3. String? tag,
  4. StackTrace? stackTrace,
  5. E? exception,
  6. dynamic errorMarkedMessage,
})
override

Implementation

@override
void printLog<E>(Level level, dynamic message,
    {String? tag, StackTrace? stackTrace, E? exception, dynamic errorMarkedMessage}) {
  try {
    assert(message != null);
    if (errorMarkedMessage != null && errorMarkedMessage is StackTrace) {
      return;
    }
    if (parameter?.logFilter == null) {
      parameter?.setLogFilter(LogFilter());
    }
    var logEvent = new LogEvent(level, message,
        tag: tag ?? "",
        stackTrace: stackTrace,
        exception: exception,
        dateTime: DateTime.now(),
        errorMarkedMessage: errorMarkedMessage);
    //过滤掉不需要打印日志
    if (!(parameter?.logFilter?.filterLog(logEvent) ?? false)) {
      return;
    }
    parameter?.logListener?.onLogListener(Future.value(logEvent));
    if (parameter?.isPrintLog ?? false) {
      var nested = logPrinter?.log(logEvent);
      if (nested != null) {
        queue.addFirst(nested);
        if (!isPrinting) {
          _performLog();
        }
      }
    }
  } catch (e) {
    print(e);
  }
}