blob: 86a192e7f54a14be218ad160d069835c70714ea1 (
plain)
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
|
-- 不能使用 debug 命名模块,会冲突,
-- 要使用其余名字比如 Debug
local debug = {}
io.stdout:setvbuf("no")
debug.LEVEL = {
INFO = 4,
DEBUG = 3,
WARN = 2,
ERROR = 1,
NONE = 0
}
debug.level = debug.LEVEL.INFO
debug.strict = function(level)
debug.level = level
end
debug.log = function(level, fmt, ...)
if level <= debug.level then
local msg = string.format(fmt, ...)
print(msg)
end
end
return debug
|