From 10615bfecb67fe673770a89072f5b3db189bf41c Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 11 Sep 2017 13:52:44 +1000 Subject: [PATCH] made logflush use the newer APIs and shit --- modules/util/logflush.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/util/logflush.lua b/modules/util/logflush.lua index 45c7332..dafaf96 100644 --- a/modules/util/logflush.lua +++ b/modules/util/logflush.lua @@ -1,14 +1,15 @@ spawn("logflushd",function() local lt = computer.uptime() + local logs = "" while true do - if computer.uptime() > lt + 60 and Log:len() > 0 then - local f = fs.open("/tmp/sys.log","ab") + _, sev, fac, line = event.pull("syslog") + 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 - for i = 1, #Log, 1024 do - fs.write(f,Log:sub(i,i+1023)) - end - fs.close(f) - Log = "" + f:write(logs) + logs = "" + f:close() end end coroutine.yield()