-
Notifications
You must be signed in to change notification settings - Fork 0
/
debugTools
51 lines (48 loc) · 1.7 KB
/
debugTools
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
45
46
47
48
49
50
51
local debugTools = {} -- create an empty table to store the functions
function debugTools.debugPrint(time, debugB, level, ...)
-- Only show debugging messages if the `debug` flag is set to `true`
if debugB then
-- Add timestamps to the output
if time == nil then
timestamp = "[nil:nil:nil]"
else
timestamp = string.format("[%02d:%02d:%02d]", time.hours, time.minutes, time.seconds)
end
if level == "error" then
setFgColor(91) -- red
print(timestamp, "ERROR:")
setFgColor(39) -- default color
print(...)
elseif level == "warning" then
setFgColor(93) -- yellow
print(timestamp, "WARNING:")
setFgColor(39) -- default color
print(...)
elseif level == "info" then
setFgColor(92) -- green
print(timestamp, "INFO:")
setFgColor(39) -- default color
print(...)
elseif level == "debug" then
setFgColor(94) -- blue
print(timestamp, "DEBUG:")
setFgColor(39) -- default color
print(...)
elseif level == "time" then
setFgColor(95) -- magenta
print(timestamp)
setFgColor(39) -- default color
elseif level == "digimon" then
setFgColor(33) -- magenta
print(timestamp, "DIGIMON:")
setFgColor(39) -- default color
print(...)
else
setFgColor(91) -- red
print(timestamp, "UNKNOWN:")
setFgColor(39) -- default color
print(...)
end
end
end
return debugTools -- return the table containing the functions