Version 0.7.0-beta
- order buttons - use numeric LogLevel over booleans - exact case option reversed (again) - smart case handling if replacement is longer than match - Deletion of all mappings
This commit is contained in:
@@ -121,18 +121,27 @@ function Grichelde:PrefixedPrint(...)
|
||||
end
|
||||
|
||||
function Grichelde:DebugPrint(obj, ...)
|
||||
local function prefixedDebugPrint(...)
|
||||
self:LogPrint(Grichelde.LOG_LEVEL.DEBUG, function(...)
|
||||
print(self.COLOR_CODES.GRAY .. self.L.AddonName .. self.COLOR_CODES.CLOSE .. ":", self:Format(...))
|
||||
end
|
||||
end, obj, ...)
|
||||
end
|
||||
|
||||
if (self.debug) then
|
||||
function Grichelde:TracePrint(obj, ...)
|
||||
self:LogPrint(Grichelde.LOG_LEVEL.TRACE, function(...)
|
||||
print(self.COLOR_CODES.DARKGRAY .. self.L.AddonName .. self.COLOR_CODES.CLOSE .. ":", self:Format(...))
|
||||
end, obj, ...)
|
||||
end
|
||||
|
||||
function Grichelde:LogPrint(logLevel, printFunc, obj, ...)
|
||||
if (self.logLevel >= logLevel) then
|
||||
local printF = printFunc or print
|
||||
if obj == nil then
|
||||
prefixedDebugPrint("<nil>")
|
||||
printF("<nil>")
|
||||
else
|
||||
if type(obj) == "string" then
|
||||
local l = select("#", ...)
|
||||
if ( l == 0 or not find(obj, "%%")) then
|
||||
prefixedDebugPrint(obj, ...)
|
||||
printF(obj, ...)
|
||||
else
|
||||
-- sanitize nil values in vararg
|
||||
local packed = { ... }
|
||||
@@ -144,48 +153,21 @@ function Grichelde:DebugPrint(obj, ...)
|
||||
-- self:tPrint(packed)
|
||||
-- cannot assign unpacked to a vararg variable and print it for debug
|
||||
local fmtMsg = format(obj, unpack(packed, 1, l)) -- manually set count as unpack() stops on nil (bug with #table)
|
||||
prefixedDebugPrint(fmtMsg)
|
||||
printF(fmtMsg)
|
||||
end
|
||||
elseif type(obj) == "table" then
|
||||
tPrint(obj, 0, {}, prefixedDebugPrint)
|
||||
tPrint(obj, 0, {}, printF)
|
||||
else
|
||||
prefixedDebugPrint(plainValue(obj))
|
||||
printF(plainValue(obj))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Grichelde:TracePrint(obj, ...)
|
||||
local function prefixedTracePrint(...)
|
||||
print(self.COLOR_CODES.DARKGRAY .. self.L.AddonName .. self.COLOR_CODES.CLOSE .. ":", self:Format(...))
|
||||
end
|
||||
function Grichelde:PrintOptions()
|
||||
self:DebugPrint(self.options.args.replacements.args)
|
||||
end
|
||||
|
||||
if (self.debug and self.trace) then
|
||||
if obj == nil then
|
||||
prefixedTracePrint("<nil>")
|
||||
else
|
||||
if type(obj) == "string" then
|
||||
local l = select("#", ...)
|
||||
if ( l == 0 or not find(obj, "%%")) then
|
||||
prefixedTracePrint(obj, ...)
|
||||
else
|
||||
-- sanitize nil values in vararg
|
||||
local packed = { ... }
|
||||
for i = 1, l do
|
||||
packed[i] = toString(packed[i]) or "nil"
|
||||
end
|
||||
|
||||
-- print("packed = ", packed)
|
||||
-- self:tPrint(packed)
|
||||
-- cannot assign unpacked to a vararg variable and print it for debug
|
||||
local fmtMsg = format(obj, unpack(packed, 1, l)) -- manually set count as unpack() stops on nil (bug with #table)
|
||||
prefixedTracePrint(fmtMsg)
|
||||
end
|
||||
elseif type(obj) == "table" then
|
||||
tPrint(obj, 0, {}, prefixedTracePrint)
|
||||
else
|
||||
prefixedTracePrint(plainValue(obj))
|
||||
end
|
||||
end
|
||||
end
|
||||
function Grichelde:PrintMappings()
|
||||
self:DebugPrint(self.db.profile.replacements)
|
||||
end
|
||||
Reference in New Issue
Block a user