Gate debugging functions added

This commit is contained in:
2026-01-01 23:43:22 -05:00
parent 9e47e04adb
commit 0906603e58
3 changed files with 34 additions and 16 deletions

View File

@ -8,10 +8,12 @@ local utils = {}
-- Import config (set by startup.lua)
local config
local gate
local chatBox
function utils.init(cfg, gateInterface)
function utils.init(cfg, gateInterface, chatBoxPeripheral)
config = cfg
gate = gateInterface
chatBox = chatBoxPeripheral
end
---------------------------------------------
@ -35,6 +37,27 @@ function utils.log(message)
end
end
function utils.debug(message)
-- Log to debug log file
local timestamp = os.date("%Y-%m-%d %H:%M:%S")
local logEntry = "[" .. timestamp .. "] " .. message
-- Write to console
print("DEBUG: " .. message)
-- Write to debug log file
local file = fs.open("gate_debug.log", "a")
if file then
file.writeLine(logEntry)
file.close()
end
-- Send to chatbox if enabled
if config.enableChatboxDebug and chatBox then
chatBox.sendMessageToPlayer("[SGC] " .. message, config.chatboxDebugPlayer)
end
end
---------------------------------------------
-- ADDRESS UTILITIES
---------------------------------------------