Better debug print

This commit is contained in:
ZioPao
2024-01-08 12:49:42 +01:00
parent 1273dc7c7a
commit cf27a24380
7 changed files with 35 additions and 17 deletions

View File

@@ -14,10 +14,28 @@ end
---@param string string
function TOC_DEBUG.print(string)
if isDebugEnabled() then
print("TOC: " .. tostring(string))
local runningFile = TOC_DEBUG.getRunningFile()
print("TOC: " .. "[" .. runningFile .. "] " .. tostring(string))
end
end
---Horrendous but I don't really care about performance for this
---@return string
function TOC_DEBUG.getRunningFile()
local coroutine = getCurrentCoroutine()
local o = getCoroutineObjStack(coroutine, 0)
if o then
local s = KahluaUtil.rawTostring2(o)
local match = string.match(s, "file: (%w+)%.lua")
if match then return match end
end
return ""
end
function TOC_DEBUG.printTable(table, indent)
if not table then return end
indent = indent or ""