序言
Harmony开发中,其中自带的日志打印使用起来感觉真的是一言难尽,感觉挺麻烦的。文章来源:https://www.toymoban.com/news/detail-683551.html
自带Log打印用法文章来源地址https://www.toymoban.com/news/detail-683551.html
public static final HiLogLabel TAGLABLE = new HiLogLabel(HiLog.LOG_APP, 0x00201, "MainAbilitySlice");
//使用
HiLog.error(TAGLABLE, "当前应用进程:" + this.getProcessInfo().getProcessName());
简单封装
public class LogUtil {
private static final int DOMAIN = 0x10086;
private static final String TAG = "LogUtil";
private static final HiLogLabel LABEL = new HiLogLabel(HiLog.LOG_APP, DOMAIN, TAG);
public static void debug(String message) {
HiLog.debug(LABEL, message);
}
public static void info(String message) {
HiLog.info(LABEL, message);
}
public static void error(String message) {
HiLog.error(LABEL, message);
}
public static void LongLog(String msg) {
int maxLogLength = 1000;
for (int i = 0; i <= msg.length() / maxLogLength; i++) {
int start = i * maxLogLength;
int end = (i + 1) * maxLogLength;
end = Math.min(end, msg.length());
error(msg.substring(start, end));
}
}
}
到了这里,关于【Harmony】日志打印工具(直接粘贴复用)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!