mirror of
https://github.com/lxsang/silk.git
synced 2025-04-24 12:56:43 +02:00
Compare commits
No commits in common. "32577500def838ed79995587924eb764584c335d" and "a6838e52949f8677c3e92ddb13ee186d1a243051" have entirely different histories.
32577500de
...
a6838e5294
@ -126,28 +126,17 @@ function loadscript(file, args)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local __MSG = function(fmt,...)
|
-- logging helpers
|
||||||
local va = {...}
|
|
||||||
local log_msg = fmt
|
|
||||||
local ret,msg = pcall(function() return string.format(fmt, table.unpack(va)) end)
|
|
||||||
if ret then
|
|
||||||
log_msg = msg
|
|
||||||
else
|
|
||||||
log_msg = string.format("Error processing format string [%s]: %s", fmt, msg)
|
|
||||||
end
|
|
||||||
return log_msg
|
|
||||||
end
|
|
||||||
|
|
||||||
function LOG_INFO(fmt, ...)
|
function LOG_INFO(fmt, ...)
|
||||||
fcgio:log_info(__MSG(fmt or "INFO",table.unpack({...})))
|
fcgio:log_info(string.format(fmt or "LOG", ...))
|
||||||
end
|
end
|
||||||
|
|
||||||
function LOG_ERROR(fmt, ...)
|
function LOG_ERROR(fmt, ...)
|
||||||
fcgio:log_error(__MSG(fmt or "ERROR",table.unpack({...})))
|
fcgio:log_error(string.format(fmt or "ERROR", ...))
|
||||||
end
|
end
|
||||||
|
|
||||||
function LOG_DEBUG(fmt, ...)
|
function LOG_DEBUG(fmt, ...)
|
||||||
fcgio:log_debug(__MSG(fmt or "DEBUG",table.unpack({...})))
|
fcgio:log_debug(string.format(fmt or "ERROR", ...))
|
||||||
end
|
end
|
||||||
|
|
||||||
function LOG_WARN(fmt, ...)
|
function LOG_WARN(fmt, ...)
|
||||||
|
@ -20,7 +20,7 @@ function utils.is_array(table)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function utils.escape(s, ignore_percent)
|
function utils.escape(s)
|
||||||
local replacements = {
|
local replacements = {
|
||||||
["\\"] = "\\\\",
|
["\\"] = "\\\\",
|
||||||
['"'] = '\\"',
|
['"'] = '\\"',
|
||||||
@ -28,11 +28,9 @@ function utils.escape(s, ignore_percent)
|
|||||||
["\t"] = "\\t",
|
["\t"] = "\\t",
|
||||||
["\b"] = "\\b",
|
["\b"] = "\\b",
|
||||||
["\f"] = "\\f",
|
["\f"] = "\\f",
|
||||||
["\r"] = "\\r"
|
["\r"] = "\\r",
|
||||||
|
["%"] = "%%"
|
||||||
}
|
}
|
||||||
if not ignore_percent then
|
|
||||||
replacements["%"] = "%%"
|
|
||||||
end
|
|
||||||
return (s:gsub("[\\'\"\n\t\b\f\r%%]", replacements))
|
return (s:gsub("[\\'\"\n\t\b\f\r%%]", replacements))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -196,8 +194,7 @@ function JSON.encode(obj)
|
|||||||
end
|
end
|
||||||
elseif t == 'string' then
|
elseif t == 'string' then
|
||||||
-- print('"'..utils.escape(obj)..'"')
|
-- print('"'..utils.escape(obj)..'"')
|
||||||
-- ignore % escape as this is for a LUA using
|
return '"' .. utils.escape(obj) .. '"'
|
||||||
return '"' .. utils.escape(obj, true) .. '"'
|
|
||||||
elseif t == 'boolean' or t == 'number' then
|
elseif t == 'boolean' or t == 'number' then
|
||||||
return tostring(obj)
|
return tostring(obj)
|
||||||
elseif obj == nil then
|
elseif obj == nil then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user