-- @runtimes lua54 luajit --- 演示:debug.getinfo 读取调用者信息。 local M = {} local function caller_name() local info = debug.getinfo(2, "nSl") if info == nil then return "?" end return tostring(info.name or info.short_src) .. ":" .. tostring(info.currentline) end local function handler() return caller_name() end --- @return table { location = string } function M.run(log) log = log or print local location = handler() log(("location=%s"):format(location)) return { location = location } end if not ... then M.run() end return M