miduo_client/Assets/ManagedResources/~Lua/Common/Debug.lua

107 lines
2.3 KiB
Lua
Raw Normal View History

2020-05-09 13:31:21 +08:00
--输出日志--
function Log(str)
2025-11-14 17:59:03 +08:00
if LogModeLevel == 0 and not AppConst.isSDKLogin then
2020-05-09 13:31:21 +08:00
Util.Log(debug.traceback(str))
end
end
--警告日志--
function LogWarn(str)
2025-11-14 17:59:03 +08:00
if LogModeLevel >= 0 and LogModeLevel <= 1 and not AppConst.isSDKLogin then
2020-05-09 13:31:21 +08:00
Util.LogWarning(debug.traceback(str))
end
end
--错误日志--
function LogError(str)
2025-11-14 17:59:03 +08:00
if LogModeLevel <= 2 and LogModeLevel >= 0 and not AppConst.isSDKLogin then
2020-05-09 13:31:21 +08:00
Util.LogError(debug.traceback(str))
end
end
2025-11-14 17:59:03 +08:00
-- print
function print(str)
Log(str)
end
2020-05-09 13:31:21 +08:00
-- 有颜色的log可自定义
2025-11-14 17:59:03 +08:00
--
function LogRed(str)
Log("<color=#f00>" .. str .. "</color>")
2020-05-09 13:31:21 +08:00
end
2025-11-14 17:59:03 +08:00
function LogGreen(str)
Log("<color=#0f0>" .. str .. "</color>")
2020-05-09 13:31:21 +08:00
end
2025-11-14 17:59:03 +08:00
function LogBlue(str)
Log("<color=#0ff>" .. str .. "</color>")
2020-05-09 13:31:21 +08:00
end
2025-11-14 17:59:03 +08:00
2020-06-03 19:09:01 +08:00
function LogPink(str)
2025-11-14 17:59:03 +08:00
Log("<color=#FF7AD7>" .. str .. "</color>")
2020-06-03 19:09:01 +08:00
end
2025-11-14 17:59:03 +08:00
2020-07-08 11:46:43 +08:00
function LogYellow(str)
2025-11-14 17:59:03 +08:00
Log("<color=yellow>" .. str .. "</color>")
2020-07-08 11:46:43 +08:00
end
2025-11-14 17:59:03 +08:00
2020-07-08 11:46:43 +08:00
function LogPurple(str)
2025-11-14 17:59:03 +08:00
Log("<color=purple>" .. str .. "</color>")
2020-07-08 11:46:43 +08:00
end
2020-06-03 19:09:01 +08:00
2020-05-09 13:31:21 +08:00
--带有颜色的打印 只支持2 4参数个数("red","") ("red","","#FFFFFF","")
function LogColor(...)
2025-11-14 17:59:03 +08:00
local args = { ... }
if #args == 2 then
Log("<color=" .. args[1] .. ">" .. args[2] .. "</color>")
elseif #args == 4 then
Log("<color=" .. args[1] .. ">" .. args[2] .. "</color>" .. " <color=" .. args[3] .. ">" .. args[4] ..
"</color>")
2020-05-09 13:31:21 +08:00
end
end
2025-11-14 17:59:03 +08:00
function PrintBattleTable(tb)
local s = "{"
if tb then
for k, v in pairs(tb) do
-- k
if type(k) == "number" then
2025-11-14 17:59:03 +08:00
s = s .. string.format("[%s]=", k)
elseif type(k) == "string" then
2025-11-14 17:59:03 +08:00
s = s .. string.format("%s=", k)
elseif type(k) == "table" then
2025-11-14 17:59:03 +08:00
s = s .. string.format("[%s]=", "table")
end
2025-11-14 17:59:03 +08:00
-- v
if type(v) == "number" or type(v) == "string" then
2025-11-14 17:59:03 +08:00
s = s .. v .. ","
elseif type(v) == "table" then
2025-11-14 17:59:03 +08:00
s = s .. PrintBattleTable(v)
end
end
end
2025-11-14 17:59:03 +08:00
return s .. "}"
end
-- 打印表
function LogGreenTable(t)
LogGreen(PrintBattleTable(t))
end
-- 打印表
function LogRedTable(t)
LogRed(PrintBattleTable(t))
end
-- 打印表
function LogBlueTable(t)
LogBlue(PrintBattleTable(t))
end
2025-11-14 17:59:03 +08:00
-- 打印表
function LogPinkTable(t)
LogPink(PrintBattleTable(t))
2025-11-14 17:59:03 +08:00
end