mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
log use strval
This commit is contained in:
parent
4d7d3be93b
commit
7d7eecaa5e
@ -53,7 +53,7 @@ end
|
|||||||
---@param msg string
|
---@param msg string
|
||||||
local _log = function (msg)
|
local _log = function (msg)
|
||||||
local time_stamp = os.date("[%c] ")
|
local time_stamp = os.date("[%c] ")
|
||||||
local stamped = time_stamp .. msg
|
local stamped = time_stamp .. util.strval(msg)
|
||||||
|
|
||||||
-- attempt to write log
|
-- attempt to write log
|
||||||
local status, result = pcall(function ()
|
local status, result = pcall(function ()
|
||||||
@ -137,8 +137,7 @@ end
|
|||||||
---@param msg string message
|
---@param msg string message
|
||||||
---@param show_term? boolean whether or not to show on terminal output
|
---@param show_term? boolean whether or not to show on terminal output
|
||||||
log.dmesg = function (msg, show_term)
|
log.dmesg = function (msg, show_term)
|
||||||
if msg == nil then return end
|
local message = string.format("[%10.3f] ", os.clock()) .. util.strval(msg)
|
||||||
local message = string.format("[%10.3f] ", os.clock()) .. msg
|
|
||||||
if show_term then _write(message) end
|
if show_term then _write(message) end
|
||||||
_log(message)
|
_log(message)
|
||||||
end
|
end
|
||||||
@ -147,7 +146,6 @@ end
|
|||||||
---@param msg string message
|
---@param msg string message
|
||||||
---@param trace? boolean include file trace
|
---@param trace? boolean include file trace
|
||||||
log.debug = function (msg, trace)
|
log.debug = function (msg, trace)
|
||||||
if msg == nil then return end
|
|
||||||
if LOG_DEBUG then
|
if LOG_DEBUG then
|
||||||
local dbg_info = ""
|
local dbg_info = ""
|
||||||
|
|
||||||
@ -162,29 +160,26 @@ log.debug = function (msg, trace)
|
|||||||
dbg_info = info.short_src .. ":" .. name .. info.currentline .. " > "
|
dbg_info = info.short_src .. ":" .. name .. info.currentline .. " > "
|
||||||
end
|
end
|
||||||
|
|
||||||
_log("[DBG] " .. dbg_info .. msg)
|
_log("[DBG] " .. dbg_info .. util.strval(msg))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- log info messages
|
-- log info messages
|
||||||
---@param msg string message
|
---@param msg string message
|
||||||
log.info = function (msg)
|
log.info = function (msg)
|
||||||
if msg == nil then return end
|
_log("[INF] " .. util.strval(msg))
|
||||||
_log("[INF] " .. msg)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- log warning messages
|
-- log warning messages
|
||||||
---@param msg string message
|
---@param msg string message
|
||||||
log.warning = function (msg)
|
log.warning = function (msg)
|
||||||
if msg == nil then return end
|
_log("[WRN] " .. util.strval(msg))
|
||||||
_log("[WRN] " .. msg)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- log error messages
|
-- log error messages
|
||||||
---@param msg string message
|
---@param msg string message
|
||||||
---@param trace? boolean include file trace
|
---@param trace? boolean include file trace
|
||||||
log.error = function (msg, trace)
|
log.error = function (msg, trace)
|
||||||
if msg == nil then return end
|
|
||||||
local dbg_info = ""
|
local dbg_info = ""
|
||||||
|
|
||||||
if trace then
|
if trace then
|
||||||
@ -198,14 +193,13 @@ log.error = function (msg, trace)
|
|||||||
dbg_info = info.short_src .. ":" .. name .. info.currentline .. " > "
|
dbg_info = info.short_src .. ":" .. name .. info.currentline .. " > "
|
||||||
end
|
end
|
||||||
|
|
||||||
_log("[ERR] " .. dbg_info .. msg)
|
_log("[ERR] " .. dbg_info .. util.strval(msg))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- log fatal errors
|
-- log fatal errors
|
||||||
---@param msg string message
|
---@param msg string message
|
||||||
log.fatal = function (msg)
|
log.fatal = function (msg)
|
||||||
if msg == nil then return end
|
_log("[FTL] " .. util.strval(msg))
|
||||||
_log("[FTL] " .. msg)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return log
|
return log
|
||||||
|
Loading…
Reference in New Issue
Block a user