log method

  1. @override
void log(
  1. String level,
  2. String message, {
  3. String? tag,
  4. dynamic ex,
  5. StackTrace? stacktrace,
  6. Map<String, String?>? attributes,
})
override

Logs message with level and optional tag, ex (exception, stacktrace

Implementation

@override
void log(
  String level,
  String message, {
  String? tag,
  dynamic ex,
  StackTrace? stacktrace,
  Map<String, String?>? attributes,
}) {
  final logTag = tag ?? LogTree.getTag();
  final logLineBuilder = StringBuffer('$level\t$logTag:\t $message');

  if (ex != null) {
    logLineBuilder.write('\n$ex');
  }
  if (stacktrace != null) {
    final tmpStacktrace = stacktrace.toString().split('\n');
    final stackTraceMessage =
        tmpStacktrace.map((stackLine) => '\t$stackLine').join('\n');
    logLineBuilder.write('\n$stackTraceMessage');
  }
  printLog(logLineBuilder.toString(), level: level);
}