made logflush use the newer APIs and shit

This commit is contained in:
Izaya 2017-09-11 13:52:44 +10:00
parent 21a9c66d8d
commit 10615bfecb

View File

@ -1,14 +1,15 @@
spawn("logflushd",function() spawn("logflushd",function()
local lt = computer.uptime() local lt = computer.uptime()
local logs = ""
while true do while true do
if computer.uptime() > lt + 60 and Log:len() > 0 then _, sev, fac, line = event.pull("syslog")
local f = fs.open("/tmp/sys.log","ab") logs = "["..tostring(computer.uptime()).."] ["..tostring(sev).."] ["..tostring(fac).."] "..tostring(v)
if computer.uptime() > lt+60 then
local f = io.open("/tmp/sys.log","ab")
if f then if f then
for i = 1, #Log, 1024 do f:write(logs)
fs.write(f,Log:sub(i,i+1023)) logs = ""
end f:close()
fs.close(f)
Log = ""
end end
end end
coroutine.yield() coroutine.yield()