aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apt-panopticommon.lua
diff options
context:
space:
mode:
authoronefang2019-12-24 19:36:45 +1000
committeronefang2019-12-24 19:36:45 +1000
commit0e034f01c189e1e7bedb7e8897680b8f322ba301 (patch)
tree5715913944c96ec7407294f6230ec84f791e91e8 /apt-panopticommon.lua
parentLog arguments. (diff)
downloadapt-panopticon-0e034f01c189e1e7bedb7e8897680b8f322ba301.zip
apt-panopticon-0e034f01c189e1e7bedb7e8897680b8f322ba301.tar.gz
apt-panopticon-0e034f01c189e1e7bedb7e8897680b8f322ba301.tar.bz2
apt-panopticon-0e034f01c189e1e7bedb7e8897680b8f322ba301.tar.xz
Refactor logging.
Diffstat (limited to 'apt-panopticommon.lua')
-rw-r--r--apt-panopticommon.lua16
1 files changed, 15 insertions, 1 deletions
diff --git a/apt-panopticommon.lua b/apt-panopticommon.lua
index d8ab129..54e2be1 100644
--- a/apt-panopticommon.lua
+++ b/apt-panopticommon.lua
@@ -315,7 +315,18 @@ APT.results = {}
315APT.logFile = nil 315APT.logFile = nil
316APT.html = false 316APT.html = false
317 317
318APT.logPre = function() 318APT.logName = function(host, a2, a3)
319 local name = host
320 if nil ~= a2 then name = name .. "_" .. a2 end
321 if nil ~= a3 then name = name .. "_" .. a3 end
322 return 'results/LOG_' .. name .. '.html'
323end
324
325APT.logOpen = function(host, a2, a3)
326 local name = APT.logName(host, a2, a3)
327 if APT.checkFile(name) then return false end
328 APT.logFile, e = io.open(name, "a+")
329 if nil == APT.logFile then C('opening log file (' .. name .. ') - ' .. e); return false end
319 if nil ~= APT.logFile then 330 if nil ~= APT.logFile then
320 APT.logFile:write("<html><head>\n") 331 APT.logFile:write("<html><head>\n")
321 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")
@@ -323,10 +334,13 @@ APT.logPre = function()
323 APT.logFile:write(APT.dumpTable(APT.args, '', 'Arguments')) 334 APT.logFile:write(APT.dumpTable(APT.args, '', 'Arguments'))
324 APT.logFile:write("</pre>\n") 335 APT.logFile:write("</pre>\n")
325 end 336 end
337 return true
326end 338end
339
327APT.logPost = function() 340APT.logPost = function()
328 if nil ~= APT.logFile then 341 if nil ~= APT.logFile then
329 APT.logFile:write("</body></html> \n") 342 APT.logFile:write("</body></html> \n")
343 APT.logFile:close()
330 end 344 end
331end 345end
332 346