test
This commit is contained in:
parent
def9e7e891
commit
f66d138c12
29
logger.lua
Normal file
29
logger.lua
Normal 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
|
||||
Loading…
Reference in New Issue
Block a user