--- lua监听器 --- Generated by EmmyLua(https://github.com/EmmyLua) --- Created by 無心道(15388152619). --- DateTime: 2024/12/6 10:36 --- require("table-extend") local LuaProfiler = {} LuaProfiler.__index = LuaProfiler ---获取函数所在的文件名 function LuaProfiler.getFunctionInfo(debugInfo) --获取不到函数名字,只能又文件名和行数表达了 --print(table.toString(debugInfo)) return (debugInfo.short_src or "匿名文件") .. ":" .. (debugInfo.name or "unknown") .. ":" .. tostring(debugInfo.linedefined) end function LuaProfiler.trigger(event, line) local funcinfo = debug.getinfo(2, 'nS') --print("Event:", LuaProfiler.getFunctionInfo(funcinfo), event) end function LuaProfiler.start() debug.sethook(LuaProfiler.trigger, "cr") end --LuaProfiler.start()