Skip to content

Commit

Permalink
优化日志显示
Browse files Browse the repository at this point in the history
  • Loading branch information
xiyuesaves committed Jun 14, 2024
1 parent e3b9eae commit e1e2023
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/render_modules/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ console.log("通信端口", port);
if (log && log.length) {
for (let i = 0; i < log.length; i++) {
const singLog = log[i];
// 过滤无效log
if (singLog?.[4]?.[1]?.[0] === "info" || singLog?.[2]?.eventName === "ns-LoggerApi-2") {
continue;
}
// 根据日志类型使用颜色区分
switch (singLog[0]) {
case "[send]":
Expand All @@ -31,9 +35,7 @@ console.log("通信端口", port);
singLog[0] = `%c${singLog[0]}`;
singLog.splice(1, 0, "background:#ffd666;color:#000000D9;padding:2px 4px;border-radius: 4px;");
}
if (singLog[3] !== "info" && (singLog?.[1] === "send" ? singLog?.[4]?.[1] : true)) {
console.log(...singLog);
}
console.log(...singLog);
}
}
} catch (err) {
Expand Down

0 comments on commit e1e2023

Please sign in to comment.