aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apt-panopticommon.lua
diff options
context:
space:
mode:
authoronefang2019-12-28 22:39:52 +1000
committeronefang2019-12-28 22:39:52 +1000
commit6e868b6382cabbacffb1d12dc91f7eb9a8362ce2 (patch)
treef14f68c1419053b787969fd210d903458ddde52a /apt-panopticommon.lua
parentNagios is no longer a report type. (diff)
downloadapt-panopticon-6e868b6382cabbacffb1d12dc91f7eb9a8362ce2.zip
apt-panopticon-6e868b6382cabbacffb1d12dc91f7eb9a8362ce2.tar.gz
apt-panopticon-6e868b6382cabbacffb1d12dc91f7eb9a8362ce2.tar.bz2
apt-panopticon-6e868b6382cabbacffb1d12dc91f7eb9a8362ce2.tar.xz
Tweak the dumpTable() arguments a little.
Diffstat (limited to 'apt-panopticommon.lua')
-rw-r--r--apt-panopticommon.lua16
1 files changed, 8 insertions, 8 deletions
diff --git a/apt-panopticommon.lua b/apt-panopticommon.lua
index cfea728..53bd674 100644
--- a/apt-panopticommon.lua
+++ b/apt-panopticommon.lua
@@ -182,8 +182,6 @@ APT.parseArgs = function(args)
182 return arg, sendArgs 182 return arg, sendArgs
183end 183end
184 184
185--print(APT.dumpTable(APT.options, "", "options"))
186
187 185
188 186
189--[[ Ordered table iterator, allow to iterate on the natural order of the keys of a table. 187--[[ Ordered table iterator, allow to iterate on the natural order of the keys of a table.
@@ -232,7 +230,8 @@ function APT.orderedPairs(t)
232end 230end
233 231
234-- Use this to dump a table to a string, with HTML. 232-- Use this to dump a table to a string, with HTML.
235APT.dumpTableHTML = function (table, space, name) 233APT.dumpTableHTML = function (table, name, space)
234 if nil == space then space = '' end
236 local r = name .. "\n" 235 local r = name .. "\n"
237 r = r .. dumpTableHTMLSub(table, space .. " ") 236 r = r .. dumpTableHTMLSub(table, space .. " ")
238 r = r .. space .. "" 237 r = r .. space .. ""
@@ -243,9 +242,9 @@ dumpTableHTMLSub = function (table, space)
243 for k, v in APT.orderedPairs(table) do 242 for k, v in APT.orderedPairs(table) do
244 if type(v) == "table" then 243 if type(v) == "table" then
245 if " " == space then 244 if " " == space then
246 r = r .. space .. APT.dumpTableHTML(v, space, k .. "<ul>") .. "</ul>\n" 245 r = r .. space .. APT.dumpTableHTML(v, k .. "<ul>", space) .. "</ul>\n"
247 else 246 else
248 r = r .. "<li>" .. space .. APT.dumpTableHTML(v, space, k .. "<ul>") .. "</ul></li>\n" 247 r = r .. "<li>" .. space .. APT.dumpTableHTML(v, k .. "<ul>", space) .. "</ul></li>\n"
249 end 248 end
250 else 249 else
251 r = r .. space .. "<li>" .. k .. "</li>\n" 250 r = r .. space .. "<li>" .. k .. "</li>\n"
@@ -255,7 +254,8 @@ dumpTableHTMLSub = function (table, space)
255end 254end
256 255
257-- Use this to dump a table to a string. 256-- Use this to dump a table to a string.
258APT.dumpTable = function (table, space, name) 257APT.dumpTable = function (table, name, space)
258 if nil == space then space = '' end
259 local r = "" 259 local r = ""
260 if "" == space then r = r .. space .. name .. " =\n" else r = r .. space .. "[" .. name .. "] =\n" end 260 if "" == space then r = r .. space .. name .. " =\n" else r = r .. space .. "[" .. name .. "] =\n" end
261 r = r .. space .. "{\n" 261 r = r .. space .. "{\n"
@@ -268,7 +268,7 @@ dumpTableSub = function (table, space)
268 for k, v in pairs(table) do 268 for k, v in pairs(table) do
269 if type(k) == "string" then k = '"' .. k .. '"' end 269 if type(k) == "string" then k = '"' .. k .. '"' end
270 if type(v) == "table" then 270 if type(v) == "table" then
271 r = r .. APT.dumpTable(v, space, k) 271 r = r .. APT.dumpTable(v, k, space)
272 elseif type(v) == "string" then 272 elseif type(v) == "string" then
273 local bq = '"' 273 local bq = '"'
274 local eq = '"' 274 local eq = '"'
@@ -331,7 +331,7 @@ APT.logOpen = function(host, a2, a3)
331 APT.logFile:write("<html><head>\n") 331 APT.logFile:write("<html><head>\n")
332 APT.logFile:write("</head><body bgcolor='black' text='white' alink='red' link='blue' vlink='purple'>\n") 332 APT.logFile:write("</head><body bgcolor='black' text='white' alink='red' link='blue' vlink='purple'>\n")
333 APT.logFile:write("<pre>\n") 333 APT.logFile:write("<pre>\n")
334 APT.logFile:write(APT.dumpTable(APT.args, '', 'Arguments')) 334 APT.logFile:write(APT.dumpTable(APT.args, 'Arguments'))
335 APT.logFile:write("</pre>\n") 335 APT.logFile:write("</pre>\n")
336 else 336 else
337 return false 337 return false