mirror of
https://github.com/lxsang/silk.git
synced 2024-12-26 21:08:22 +01:00
improve log function
All checks were successful
gitea-sync/silk/pipeline/head This commit looks good
All checks were successful
gitea-sync/silk/pipeline/head This commit looks good
This commit is contained in:
parent
7dcfa9c8f0
commit
32577500de
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user