-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrace.lua
More file actions
43 lines (31 loc) · 821 Bytes
/
Trace.lua
File metadata and controls
43 lines (31 loc) · 821 Bytes
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
require ("init")
local Debug = require("dbg")
local Trace = {}
function Trace:new(n)
local t = {}
setmetatable(t, self)
self.__index = self
t.Name = n
return t
end
local function logTrace(self, phase, msg)
local lev = Debug.Level or LEVEL.ERROR
if lev.Cod >= LEVEL.TRACE.Cod then
local sRet = string.format("%s(%s):%s", phase, self.Name, msg)
print(sRet)
end
end
function Trace:beginTrace(...)
logTrace(self, "Begin", Debug.tostring({...}))
end
function Trace:body(id, msg, ...)
local args,msgArgs = {...},""
if #args ~= 0 then
msgArgs = Debug.tostring(args)
end
logTrace(self, "Body", string.format("id=%s %s:%s", id, msg, msgArgs))
end
function Trace:endTrace(...)
logTrace(self, "End", Debug.tostring({...}))
end
return Trace