Cleanup logging
parent
793c097b03
commit
469dbd257f
23
init.lua
23
init.lua
|
@ -14,6 +14,29 @@ listitems = {}
|
|||
listitems.modname = core.get_current_modname()
|
||||
listitems.modpath = core.get_modpath(listitems.modname)
|
||||
|
||||
function listitems.log(lvl, msg)
|
||||
if not msg then
|
||||
msg = lvl
|
||||
lvl = nil
|
||||
end
|
||||
|
||||
local prefix = "[" .. listitems.modname .. "]"
|
||||
if lvl == "debug" then
|
||||
if not listitems.debug then return end
|
||||
|
||||
prefix = prefix .. "[DEBUG]"
|
||||
end
|
||||
|
||||
msg = prefix .. " " .. msg
|
||||
|
||||
if not lvl then
|
||||
core.log(msg)
|
||||
else
|
||||
core.log(lvl, msg)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local scripts = {
|
||||
"settings",
|
||||
"logging",
|
||||
|
|
15
logging.lua
15
logging.lua
|
@ -11,31 +11,28 @@
|
|||
-- LOGGING FUNCTIONS
|
||||
|
||||
-- Custom logging function
|
||||
function listitems.log(level, msg)
|
||||
local prefix = "[" .. listitems.modname .. "] "
|
||||
|
||||
if msg == nil then
|
||||
core.log(prefix .. level)
|
||||
else
|
||||
core.log(level, prefix .. msg)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Custom "info" level logging function
|
||||
function listitems.logInfo(msg)
|
||||
listitems.log("warning", "\"listitems.logInfo\" is deprecated, use \"listitems.log\"")
|
||||
|
||||
listitems.log("info", msg)
|
||||
end
|
||||
|
||||
|
||||
-- Custom "warning" level logging function
|
||||
function listitems.logWarn(msg)
|
||||
listitems.log("warning", "\"listitems.logWarn\" is deprecated, use \"listitems.log\"")
|
||||
|
||||
listitems.log("warning", msg)
|
||||
end
|
||||
|
||||
|
||||
-- Custom debug logging function
|
||||
function listitems.logDebug(msg)
|
||||
listitems.log("warning", "\"listitems.logDebug\" is deprecated, use \"listitems.log\"")
|
||||
|
||||
if listitems.debug then
|
||||
core.log("[DEBUG: " .. listitems.modname .. "] " .. msg)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue