feat: add caller information to debug logs (#1534)

This commit is contained in:
adasauce
2025-03-11 15:56:59 -03:00
committed by GitHub
parent 9552a960ef
commit 70124ad366

View File

@@ -397,8 +397,17 @@ function M.debug(...)
local args = { ... }
if #args == 0 then return end
-- Get caller information
local info = debug.getinfo(2, "Sl")
local caller_source = info.source:match("@(.+)$") or "unknown"
local caller_module = caller_source:gsub("^.*/lua/", ""):gsub("%.lua$", ""):gsub("/", ".")
local timestamp = os.date("%Y-%m-%d %H:%M:%S")
local formated_args = { "[" .. timestamp .. "] [AVANTE] [DEBUG]" }
local formated_args = {
"[" .. timestamp .. "] [AVANTE] [DEBUG] [" .. caller_module .. ":" .. info.currentline .. "]",
}
for _, arg in ipairs(args) do
if type(arg) == "string" then
table.insert(formated_args, arg)