Gate debugging functions added
This commit is contained in:
25
utils.lua
25
utils.lua
@ -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
|
||||
---------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user