2023-08-02 22:15:03 -04:00
|
|
|
--#include "module/ocelot-debug.lua"
|
2019-11-08 21:16:17 -05:00
|
|
|
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
|
|
|
|
|
2020-05-12 03:55:05 -04:00
|
|
|
-- function syslog(msg, level, service) -- string number string -- -- Output *msg* to the system log, with severity *level*, from *service*.
|
2019-11-08 21:16:17 -05:00
|
|
|
local rdprint=dprint or function() end
|
2019-07-14 06:52:56 -04:00
|
|
|
setmetatable(syslog,{__call = function(_,msg, level, service)
|
2019-11-08 21:16:17 -05:00
|
|
|
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})
|
2019-11-08 21:16:17 -05:00
|
|
|
function dprint(...)
|
|
|
|
for k,v in pairs({...}) do
|
|
|
|
syslog(v,syslog.debug)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|