feat: add caller information to debug logs (#1534)
This commit is contained in:
@@ -397,8 +397,17 @@ function M.debug(...)
|
|||||||
|
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
if #args == 0 then return end
|
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 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
|
for _, arg in ipairs(args) do
|
||||||
if type(arg) == "string" then
|
if type(arg) == "string" then
|
||||||
table.insert(formated_args, arg)
|
table.insert(formated_args, arg)
|
||||||
|
|||||||
Reference in New Issue
Block a user