add core.get_log()

This commit is contained in:
takase1121
2021-09-07 14:59:03 +02:00
committed by Francesco Abbate
parent afaf0a718d
commit 622b162225
+17
View File
@@ -881,6 +881,23 @@ function core.error(...)
end
function core.get_log(i)
if i == nil then
local r = {}
for _, item in ipairs(core.log_items) do
table.insert(r, core.get_log(item))
end
return table.concat(r, "\n")
end
local item = type(i) == "number" and core.log_items[i] or i
local text = string.format("[%s] %s at %s", os.date(nil, item.time), item.text, item.at)
if item.info then
text = string.format("%s\n%s\n", text, item.info)
end
return text
end
function core.try(fn, ...)
local err
local ok, res = xpcall(fn, function(msg)