forked from rcore-cz/rcore_ck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.lua
75 lines (71 loc) · 1.97 KB
/
debug.lua
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function sprint(msg,...)
return string.format(msg,...)
end
function isAllowed(level)
if Config.Debug then
if isTable(Config.DebugLevel) and not emptyTable(Config.DebugLevel) then
for _,lev in pairs(Config.DebugLevel) do
if lev == level then
return true
end
end
return false
else
if level == Config.DebugLevel then
return true
end
return false
end
end
end
function rdebug()
local self = {}
self.prefix = 'rcore'
self.info = function(msg,...)
if isAllowed('INFO') then
print('^5['..self.prefix..'|info] ^7'..sprint(msg,...))
end
end
self.success = function(msg,...)
if isAllowed('SUCCESS') then
print('^5['..self.prefix..'|success] ^7'..sprint(msg,...))
end
end
self.critical = function(msg,...)
if isAllowed('CRITICAL') then
print('^1['..self.prefix..'|critical] ^7'..sprint(msg,...))
end
end
self.error = function(msg,...)
if isAllowed('ERROR') then
print('^1['..self.prefix..'|error] ^7'..sprint(msg,...))
end
end
self.security = function(msg,...)
if isAllowed('SECURITY') then
print('^3['..self.prefix..'|security] ^7'..sprint(msg,...))
end
end
self.securitySpam = function(msg,...)
if isAllowed('SECURITY_SPAM') then
print('^3['..self.prefix..'|security] ^7'..sprint(msg,...))
end
end
self.debug = function(msg,...)
if isAllowed('DEBUG') then
print('^2['..self.prefix..'|debug] ^7'..sprint(msg,...))
end
end
self.setupPrefix = function(prefix)
self.prefix = prefix
end
self.getPrefix = function()
return self.prefix
end
return self
end
exports('rdebug',rdebug)
function dprint(str, ...)
local dbg = rdebug()
dbg.info(str,...)
end