-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathPlater_Logs.lua
41 lines (35 loc) · 1.17 KB
/
Plater_Logs.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
local _
local addonName, platerInternal = ...
function platerInternal.Date.GetDateForLogs()
return date("%Y-%m-%d %H:%M:%S")
end
---get the table which can save logs and errors
---@return {_general_logs: string[], _error_logs: string[]}
function platerInternal.Logs.GetLogs()
---@type {_general_logs: string[], _error_logs: string[]}
local platerLogs = PlaterLogs
if (not platerLogs) then
PlaterLogs = { --[[GLOBAL]]
_general_logs = {},
_error_logs = {},
}
return PlaterLogs
end
platerLogs._error_logs = platerLogs._error_logs or {}
platerLogs._general_logs = platerLogs._general_logs or {}
return platerLogs
end
function platerInternal.Logs.Log(text)
if (type(text) == "string") then
local platerLogs = platerInternal.Logs.GetLogs()
table.insert(platerLogs._general_logs, 1, platerInternal.Date.GetDateForLogs() .. " | " .. text)
table.remove(platerLogs._general_logs, 20)
end
end
function platerInternal.Logs.LogError(text)
if (type(text) == "string") then
local platerLogs = platerInternal.Logs.GetLogs()
table.insert(platerLogs._error_logs, 1, platerInternal.Date.GetDateForLogs() .. " | " .. text)
table.remove(platerLogs._error_logs, 10)
end
end