chore(client): 优化日志输出并清理测试代码
1. 引入全局 `CONFIG.DEBUG` 配置项(默认为 `false`),将所有 `Utils.log(DEBUG, ...)` 的大量扫描和推算日志默认隐藏,避免刷屏 CC 终端,需要时可通过配置文件开启。 2. 移除了排查 NBT 结构时添加的 `stop_dump.json` 导出逻辑,保持主机系统文件整洁。
This commit is contained in:
+2
-11
@@ -18,7 +18,7 @@ local CONFIG = {
|
|||||||
ALERT_COOLDOWN_MS = 300000,
|
ALERT_COOLDOWN_MS = 300000,
|
||||||
APPROACHING_COOLDOWN_MS = 120000,
|
APPROACHING_COOLDOWN_MS = 120000,
|
||||||
APPROACHING_STABLE_MS = 5000,
|
APPROACHING_STABLE_MS = 5000,
|
||||||
DEBUG = true
|
DEBUG = false
|
||||||
}
|
}
|
||||||
|
|
||||||
local dfpwm = require "cc.audio.dfpwm"
|
local dfpwm = require "cc.audio.dfpwm"
|
||||||
@@ -154,6 +154,7 @@ end
|
|||||||
local Utils = {}
|
local Utils = {}
|
||||||
|
|
||||||
function Utils.log(level, message)
|
function Utils.log(level, message)
|
||||||
|
if level == "DEBUG" and not CONFIG.DEBUG then return end
|
||||||
local timestamp = os.date("%H:%M:%S")
|
local timestamp = os.date("%H:%M:%S")
|
||||||
local entryText = string.format("[%s][%s] %s", timestamp, level, message)
|
local entryText = string.format("[%s][%s] %s", timestamp, level, message)
|
||||||
local entry = { level = level, text = entryText }
|
local entry = { level = level, text = entryText }
|
||||||
@@ -2640,16 +2641,6 @@ function Main.loop()
|
|||||||
cleanupTimestampMap(State.announcedAlerts, now, tonumber(CONFIG.ALERT_COOLDOWN_MS) or 300000)
|
cleanupTimestampMap(State.announcedAlerts, now, tonumber(CONFIG.ALERT_COOLDOWN_MS) or 300000)
|
||||||
|
|
||||||
for i, stop in ipairs(data.TrainStops) do
|
for i, stop in ipairs(data.TrainStops) do
|
||||||
-- [DEBUG] Dump first stop to file for inspection
|
|
||||||
if i == 1 and not State.dumpedStop then
|
|
||||||
State.dumpedStop = true
|
|
||||||
local f = fs.open("stop_dump.json", "w")
|
|
||||||
if f then
|
|
||||||
f.write(textutils.serializeJSON(stop))
|
|
||||||
f.close()
|
|
||||||
Utils.log("DEBUG", "Dumped stop structure to stop_dump.json")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local st = stop.Station
|
local st = stop.Station
|
||||||
if st then
|
if st then
|
||||||
local trainName = st.TrainName or "Unknown"
|
local trainName = st.TrainName or "Unknown"
|
||||||
|
|||||||
Reference in New Issue
Block a user