more logging improvements

This commit is contained in:
Izaya 2017-09-08 14:50:34 +10:00
parent fa15579f9f
commit e745ae05e9

View File

@ -1,6 +1,7 @@
_G.DEFAC, _G.DESEV = 6, 0 _G.DEFAC, _G.DESEV = 6, 0
if component then if component then
_G.Log = "" _G.Log = ""
_G.logt = {}
function log(...) function log(...)
local ta = {...} local ta = {...}
local sev, fac = _G.DEFAC, _G.DESEV local sev, fac = _G.DEFAC, _G.DESEV
@ -12,8 +13,15 @@ if component then
if component.list("ocemu")() then if component.list("ocemu")() then
component.invoke(component.list("ocemu")(),"log",v) component.invoke(component.list("ocemu")(),"log",v)
end end
Log=Log.."["..tostring(computer.uptime()).."] ["..tostring(sev).."] ["..tostring(fac).."] "..tostring(v).."\n" logt[#logt+1] = "["..tostring(computer.uptime()).."] ["..tostring(sev).."] ["..tostring(fac).."] "..tostring(v)
computer.pushSignal("syslog",sev,fac,v) computer.pushSignal("syslog",sev,fac,v)
if #logt > 16 then
table.remove(logt,1)
end
end
Log = ""
for k,v in ipairs(logt) do
Log=Log .. v .. "\n"
end end
end end
print=log print=log