Files
UnrealLuaDemo/Script/lua/Framework/Log.lua
T

30 lines
745 B
Lua
Raw Normal View History

local ____exports = {}
---
-- @noSelfInFile
local TAG = "[UnrealLuaDemo]"
local function FormatMessage(level, fmt, ...)
local args = {...}
local fmtStr = tostring(fmt)
local msg
if #args > 0 then
local ok, formatted = pcall(
string.format,
fmtStr,
table.unpack(args)
)
msg = ok and formatted or fmtStr
else
msg = fmtStr
end
return string.format("%s[%s] %s", TAG, level, msg)
end
function ____exports.Info(fmt, ...)
print(FormatMessage("INFO", fmt, ...))
end
function ____exports.Warn(fmt, ...)
print(FormatMessage("WARN", fmt, ...))
end
function ____exports.Error(fmt, ...)
print(FormatMessage("ERROR", fmt, ...))
end
return ____exports