diff options
| author | takase1121 <20792268+takase1121@users.noreply.github.com> | 2021-08-22 19:32:45 +0800 |
|---|---|---|
| committer | Francesco <francesco.bbt@gmail.com> | 2021-08-24 11:31:22 +0200 |
| commit | 7c3daa0f39de24cea3ddc5345d23be2aa0dfbbdc (patch) | |
| tree | f4a40311906080bd191e99323a29a0fcf7ada911 | |
| parent | cb639700b3ba7a890a46ac25f4f2c7ede767673b (diff) | |
| download | lite-xl-7c3daa0f39de24cea3ddc5345d23be2aa0dfbbdc.tar.gz lite-xl-7c3daa0f39de24cea3ddc5345d23be2aa0dfbbdc.zip | |
add core.get_log()
| -rw-r--r-- | data/core/init.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/data/core/init.lua b/data/core/init.lua index 4af35921..c71322d1 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -874,6 +874,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) |
