more logging improvements

This commit is contained in:
Izaya 2017-09-08 14:50:34 +10:00
parent fa15579f9f
commit e745ae05e9
1 changed files with 9 additions and 1 deletions

View File

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