-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebug.lua
More file actions
44 lines (39 loc) · 1.15 KB
/
Debug.lua
File metadata and controls
44 lines (39 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
local AddOnFolderName = ... ---@type string
local private = select(2, ...) ---@class PrivateNamespace
-- the DebugLog addon
---@diagnostic disable-next-line: undefined-global
local D = DLAPI
--- An empty function
local function EmptyFunc()
end
--- Adds a debug message to the DebugLog log
---@param ... any Messages to add to the debug log
local function Debug(...)
local msg = ""
for i = 1, select("#", ...) do
local arg = select(i, ...)
msg = msg .. tostring(arg) .. " "
end
D.DebugLog(AddOnFolderName, "%s", msg)
end
--- Adds a stack trace to the DebugLog log
---@diagnostic disable: undefined-field
local function Trace()
D.DebugLog(AddOnFolderName, "%s", "======== Trace ==")
local stack = debugstack(2)
for i, v in ipairs(strsplittable("\n", stack)) do
if v ~= "" then
D.DebugLog(AddOnFolderName, "%d: %s", i, v)
end
end
D.DebugLog(AddOnFolderName, "%s", "-----------------")
end
if D then
private.Debug = Debug
private.Trace = Trace
SetCVar("fstack_preferParentKeys", 0)
Debug("DebugLog setup complete")
else
private.Debug = EmptyFunc
private.Trace = EmptyFunc
end