nightly commit
This commit is contained in:
@@ -5,7 +5,7 @@ if not HMGT then return end
|
||||
local L = HMGT.L or LibStub("AceLocale-3.0"):GetLocale(ADDON_NAME)
|
||||
|
||||
HMGT.devToolsBuffer = HMGT.devToolsBuffer or {}
|
||||
HMGT.devToolsBufferMax = HMGT.devToolsBufferMax or 300
|
||||
HMGT.devToolsBufferMax = HMGT.devToolsBufferMax or 500
|
||||
|
||||
local DEVTOOLS_SCOPE_ALL = "ALL"
|
||||
local DEVTOOLS_SCOPE_LABELS = {
|
||||
@@ -20,7 +20,8 @@ local DEVTOOLS_SCOPE_LABELS = {
|
||||
|
||||
local DEVTOOLS_LEVELS = {
|
||||
error = 1,
|
||||
trace = 2,
|
||||
info = 2,
|
||||
verbose = 3,
|
||||
}
|
||||
|
||||
local function TrimText(value)
|
||||
@@ -76,8 +77,10 @@ function HMGT:GetDevToolsSettings()
|
||||
profile.devTools = type(profile.devTools) == "table" and profile.devTools or {}
|
||||
local settings = profile.devTools
|
||||
settings.enabled = settings.enabled == true
|
||||
if settings.level ~= "error" and settings.level ~= "trace" then
|
||||
settings.level = "error"
|
||||
if settings.level == "trace" then
|
||||
settings.level = "verbose"
|
||||
elseif settings.level ~= "error" and settings.level ~= "info" and settings.level ~= "verbose" then
|
||||
settings.level = "info"
|
||||
end
|
||||
if type(settings.scope) ~= "string" or settings.scope == "" then
|
||||
settings.scope = DEVTOOLS_SCOPE_ALL
|
||||
@@ -94,24 +97,25 @@ function HMGT:IsDevToolsEnabled()
|
||||
end
|
||||
|
||||
function HMGT:GetDevToolsLevelOptions()
|
||||
return {
|
||||
error = L["OPT_DEVTOOLS_LEVEL_ERROR"] or "Errors",
|
||||
trace = L["OPT_DEVTOOLS_LEVEL_TRACE"] or "Trace",
|
||||
}
|
||||
return self:GetDebugLevelOptions()
|
||||
end
|
||||
|
||||
function HMGT:GetConfiguredDevToolsLevel()
|
||||
return self:GetDevToolsSettings().level or "error"
|
||||
return self:GetConfiguredDebugLevel()
|
||||
end
|
||||
|
||||
function HMGT:ShouldIncludeDevToolsLevel(level)
|
||||
local configured = self:GetConfiguredDevToolsLevel()
|
||||
return (DEVTOOLS_LEVELS[tostring(level or "error")] or DEVTOOLS_LEVELS.error)
|
||||
<= (DEVTOOLS_LEVELS[configured] or DEVTOOLS_LEVELS.error)
|
||||
local normalizedLevel = tostring(level or "info")
|
||||
if normalizedLevel == "trace" then
|
||||
normalizedLevel = "verbose"
|
||||
end
|
||||
return (DEVTOOLS_LEVELS[normalizedLevel] or DEVTOOLS_LEVELS.info)
|
||||
<= (DEVTOOLS_LEVELS[configured] or DEVTOOLS_LEVELS.info)
|
||||
end
|
||||
|
||||
function HMGT:GetDevToolsScopeOptions()
|
||||
local values = {
|
||||
local values = self:GetDebugScopeOptions() or {
|
||||
[DEVTOOLS_SCOPE_ALL] = L["OPT_DEVTOOLS_SCOPE_ALL"] or "All scopes",
|
||||
}
|
||||
for scope, label in pairs(DEVTOOLS_SCOPE_LABELS) do
|
||||
@@ -128,8 +132,11 @@ end
|
||||
|
||||
function HMGT:FormatDevToolsEntry(entry)
|
||||
local stamp = tostring(entry and entry.stamp or date("%H:%M:%S"))
|
||||
local level = string.upper(tostring(entry and entry.level or "error"))
|
||||
local level = string.upper(tostring(entry and entry.level or "info"))
|
||||
local scope = tostring(entry and entry.scope or "System")
|
||||
if entry and entry.kind == "debug" then
|
||||
return string.format("%s [%s][%s] %s", stamp, level, scope, tostring(entry.message or ""))
|
||||
end
|
||||
local eventName = tostring(entry and entry.event or "")
|
||||
local payload = TrimText(entry and entry.payload or "")
|
||||
if payload ~= "" then
|
||||
@@ -164,8 +171,10 @@ function HMGT:RecordDevEvent(level, scope, eventName, payload)
|
||||
end
|
||||
|
||||
local normalizedLevel = tostring(level or "error")
|
||||
if normalizedLevel ~= "error" and normalizedLevel ~= "trace" then
|
||||
normalizedLevel = "trace"
|
||||
if normalizedLevel == "trace" then
|
||||
normalizedLevel = "verbose"
|
||||
elseif normalizedLevel ~= "error" and normalizedLevel ~= "info" and normalizedLevel ~= "verbose" then
|
||||
normalizedLevel = "verbose"
|
||||
end
|
||||
if not self:ShouldIncludeDevToolsLevel(normalizedLevel) then
|
||||
return
|
||||
@@ -182,6 +191,7 @@ function HMGT:RecordDevEvent(level, scope, eventName, payload)
|
||||
scope = normalizedScope,
|
||||
event = TrimText(eventName or "event"),
|
||||
payload = EncodePayloadValue(payload, 0),
|
||||
kind = "event",
|
||||
}
|
||||
|
||||
table.insert(self.devToolsBuffer, entry)
|
||||
@@ -194,6 +204,40 @@ function HMGT:RecordDevEvent(level, scope, eventName, payload)
|
||||
end
|
||||
end
|
||||
|
||||
function HMGT:RecordDebugEntry(level, scope, message)
|
||||
if not self:IsDevToolsEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
local normalizedLevel = tostring(level or "info")
|
||||
if normalizedLevel == "trace" then
|
||||
normalizedLevel = "verbose"
|
||||
elseif normalizedLevel ~= "error" and normalizedLevel ~= "info" and normalizedLevel ~= "verbose" then
|
||||
normalizedLevel = "info"
|
||||
end
|
||||
|
||||
local normalizedScope = TrimText(scope or "General")
|
||||
if normalizedScope == "" then
|
||||
normalizedScope = "General"
|
||||
end
|
||||
|
||||
self.devToolsBuffer = self.devToolsBuffer or {}
|
||||
self.devToolsBuffer[#self.devToolsBuffer + 1] = {
|
||||
stamp = date("%H:%M:%S"),
|
||||
level = normalizedLevel,
|
||||
scope = normalizedScope,
|
||||
message = TrimText(message or ""),
|
||||
kind = "debug",
|
||||
}
|
||||
while #self.devToolsBuffer > (tonumber(self.devToolsBufferMax) or 500) do
|
||||
table.remove(self.devToolsBuffer, 1)
|
||||
end
|
||||
|
||||
if self.devToolsWindow and self.devToolsWindow:IsShown() and self.RefreshDevToolsWindow then
|
||||
self:RefreshDevToolsWindow()
|
||||
end
|
||||
end
|
||||
|
||||
function HMGT:DevError(scope, eventName, payload)
|
||||
self:RecordDevEvent("error", scope, eventName, payload)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user