add static method
void
add({})
添加日志
type 类型 info/debug/warn/error
title 标题
content 内容
hasPrintLog 是否控制台打印
hasWriteLog 是否写入记录日志
Implementation
static void add({
PrintType type = PrintType.info,
String title = '',
required Object content,
bool? hasPrintLog,
bool? hasWriteLog,
}) {
final logEntity = PrintEntity(
type: type,
title: title,
content: content.toString(),
startTime: DateTime.now(),
showDetail: false,
);
if (hasWriteLog == true && DLogger.config.hasWriteLog) {
list.add(logEntity);
_clearWhenTooMuch();
length.value++;
}
if (hasPrintLog == true && DLogger.config.hasPrintLog) {
final StringBuffer sb = StringBuffer();
sb.writeln("${logEntity.type.printFlag()}[${logEntity.startTime.toString()}][${DHelper.getNavigationFile()}]");
if (logEntity.title.isNotEmpty) sb.writeln(title);
sb.writeln("\nData:${DHelper.convertJsonString(content)}");
log(sb.toString());
}
}