This commit is contained in:
Laurie Fisher 2025-06-27 14:25:46 +01:00
parent def9e7e891
commit f66d138c12
Signed by: PinkEyedOrphan
GPG Key ID: 7F827B68147AEE76

29
logger.lua Normal file
View File

@ -0,0 +1,29 @@
local M = {}
local logLines = {}
local maxLines = 5
function M.log(msg)
local time = textutils.formatTime(os.time(), true)
local entry = string.format("[%s] %s", time, msg)
table.insert(logLines, entry)
if #logLines > maxLines then
table.remove(logLines, 1)
end
M.draw()
end
function M.draw()
local w, h = term.getSize()
for i = 1, maxLines do
term.setCursorPos(1, h - maxLines + i)
term.clearLine()
if logLines[i] then
term.write(logLines[i])
end
end
end
return M