From 0e034f01c189e1e7bedb7e8897680b8f322ba301 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 24 Dec 2019 19:36:45 +1000 Subject: Refactor logging. --- apt-panopticommon.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'apt-panopticommon.lua') 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 = {} APT.logFile = nil APT.html = false -APT.logPre = function() +APT.logName = function(host, a2, a3) + local name = host + if nil ~= a2 then name = name .. "_" .. a2 end + if nil ~= a3 then name = name .. "_" .. a3 end + return 'results/LOG_' .. name .. '.html' +end + +APT.logOpen = function(host, a2, a3) + local name = APT.logName(host, a2, a3) + if APT.checkFile(name) then return false end + APT.logFile, e = io.open(name, "a+") + if nil == APT.logFile then C('opening log file (' .. name .. ') - ' .. e); return false end if nil ~= APT.logFile then APT.logFile:write("\n") APT.logFile:write("\n") @@ -323,10 +334,13 @@ APT.logPre = function() APT.logFile:write(APT.dumpTable(APT.args, '', 'Arguments')) APT.logFile:write("\n") end + return true end + APT.logPost = function() if nil ~= APT.logFile then APT.logFile:write(" \n") + APT.logFile:close() end end -- cgit v1.1