OC-PsychOS/modules/util/logflush.lua

18 lines
419 B
Lua
Raw Permalink Normal View History

spawn("logflushd",function()
local lt = computer.uptime()
local logs = ""
while true do
_, 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
f:write(logs)
logs = ""
f:close()
end
end
coroutine.yield()
end
end)