-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathLog.lua
More file actions
51 lines (44 loc) · 932 Bytes
/
Copy pathLog.lua
File metadata and controls
51 lines (44 loc) · 932 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
44
45
46
47
48
49
50
51
local Log = {}
local ZGV=ZygorGuidesViewer
if not ZGV then return end
ZGV.Log = Log
Log.entries = {}
Log.size = 100
Log.loud = false
function Log:SetSize(size)
self.size = size
self:Trim()
end
function Log:Trim()
local len = #self.entries
if len>self.size then
for i=1,len-self.size,1 do
table.remove(self.entries,1)
end
end
end
function Log:Add(s)
table.insert(self.entries,date("%H:%M:%S").."> "..s)
if #self.entries>self.size then
table.remove(self.entries,1)
end
if self.loud then
ChatFrame1:AddMessage("|cff8888ff"..date("%H:%M:%S")..">|r |cffccccff"..s.."|r")
end
end
function Log:Print(n)
local len = #self.entries
if not n or n>len then n=len end
for i=len-n+1,len,1 do
ChatFrame1:AddMessage(self.entries[i])
end
end
function Log:Dump(n)
local s = ""
local len = #self.entries
if not n or n>len then n=len end
for i=len-n+1,len,1 do
s = s .. self.entries[i] .. "\n"
end
return s
end