1
1
mirror of https://git.shadowkat.net/izaya/OC-PsychOS2.git synced 2024-11-15 17:18:08 -05:00
OC-PsychOS2/module/syslog.lua

24 lines
581 B
Lua
Raw Normal View History

do
2019-07-14 06:52:56 -04:00
syslog = {}
syslog.emergency = 0
syslog.alert = 1
syslog.critical = 2
syslog.error = 3
syslog.warning = 4
syslog.notice = 5
syslog.info = 6
syslog.debug = 7
local rdprint=dprint or function() end
2019-07-14 06:52:56 -04:00
setmetatable(syslog,{__call = function(_,msg, level, service)
level, service = level or syslog.info, service or (os.taskInfo(os.pid()) or {}).name or "unknown"
rdprint(string.format("syslog: [%s:%d/%d] %s",service,os.pid(),level,msg))
2019-07-14 06:52:56 -04:00
computer.pushSignal("syslog",msg, level, service)
end})
function dprint(...)
for k,v in pairs({...}) do
syslog(v,syslog.debug)
end
end
end