From 9a32a00c733f7b53d92933c011a51dcbd7e23e3a Mon Sep 17 00:00:00 2001 From: rxi Date: Wed, 22 Apr 2020 00:02:35 +0100 Subject: [PATCH] Made core.log/error store call location instead of view --- data/core/init.lua | 5 +++-- data/core/logview.lua | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/data/core/init.lua b/data/core/init.lua index 1690a72..dcdfae0 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -231,8 +231,9 @@ local function log(icon, icon_color, fmt, ...) core.status_view:show_message(icon, icon_color, text) end - local view = core.active_view and core.active_view:get_name() - local item = { text = text, time = os.time(), view = view } + local info = debug.getinfo(2, "Sl") + local at = string.format("%s:%d", info.short_src, info.currentline) + local item = { text = text, time = os.time(), at = at } table.insert(core.log_items, item) if #core.log_items > config.max_log_items then table.remove(core.log_items, 1) diff --git a/data/core/logview.lua b/data/core/logview.lua index 96fd594..06a8516 100644 --- a/data/core/logview.lua +++ b/data/core/logview.lua @@ -51,7 +51,7 @@ function LogView:draw() x = x + style.padding.x local subx = x x = renderer.draw_text(style.font, item.text, x, y, style.text) - x = renderer.draw_text(style.font, " in " .. item.view, x, y, style.dim) + x = renderer.draw_text(style.font, " at " .. item.at, x, y, style.dim) y = y + th if item.info then for line in item.info:gmatch("[^\n]+") do