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