improve log function
All checks were successful
gitea-sync/silk/pipeline/head This commit looks good

This commit is contained in:
DanyLE 2023-07-07 20:01:59 +02:00
parent 7dcfa9c8f0
commit 32577500de

View File

@ -128,18 +128,12 @@ end
local __MSG = function(fmt,...) local __MSG = function(fmt,...)
local va = {...} local va = {...}
if va then
local out = {}
for i,v in ipairs(va) do
local esc = v:gsub("[%%]", {["%"] = "%%"})
table.insert(out, esc)
end
va = out
end
local log_msg = fmt local log_msg = fmt
local ret,msg = pcall(function() return string.format(fmt, table.unpack(va)) end) local ret,msg = pcall(function() return string.format(fmt, table.unpack(va)) end)
if msg then if ret then
log_msg = msg log_msg = msg
else
log_msg = string.format("Error processing format string [%s]: %s", fmt, msg)
end end
return log_msg return log_msg
end end