From 0e034f01c189e1e7bedb7e8897680b8f322ba301 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 24 Dec 2019 19:36:45 +1000 Subject: Refactor logging. --- apt-panopticon.lua | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'apt-panopticon.lua') diff --git a/apt-panopticon.lua b/apt-panopticon.lua index 45a591f..649346a 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua @@ -922,13 +922,7 @@ if 0 < #arg then if APT.origin or APT.redir then APT.results["IPs"] = gatherIPs(pu.host) end - local logname = pu.host - if nil ~= arg[2] then logname = logname .. "_" .. arg[2] end - if nil ~= arg[3] then logname = logname .. "_" .. arg[3] end - if APT.checkFile("results/LOG_" .. logname .. ".html") then return end - APT.logFile, e = io.open("results/LOG_" .. logname .. ".html", "a+") - if nil == APT.logFile then C("opening log file - " .. e); return end - APT.logPre() + if not APT.logOpen(pu.host, arg[2], arg[3]) then return end I("Starting tests for " .. arg[1] .. " with these tests - " .. table.concat(APT.options.tests.value, ", ")) if nil ~= arg[2] then I(" Using IP " .. arg[2]); ip = arg[2] end if nil ~= arg[3] then I(" Using file " .. arg[3]); end @@ -1005,7 +999,6 @@ os.execute('sleep 1') -- Wait for things to start up before checking for them. end APT.logPost() - APT.logFile:close() else local fadt = io.popen("ls -dl results_old 2>/dev/null | cut -d '>' -f 2 | cut -d ' ' -f 2") local adt = fadt:read('*l') @@ -1024,9 +1017,7 @@ else os.execute("rm -f results/*.txt 2>/dev/null") end - APT.logFile, e = io.open("results/LOG_apt-panopticon.html", "a+") - if nil == APT.logFile then C("opening log file - " .. e); return end - APT.logPre() + if not APT.logOpen('apt-panopticon') then return end I("Starting tests " .. table.concat(APT.options.tests.value, ", ")) os.execute("mkdir -p results") APT.mirrors = getMirrors() @@ -1069,5 +1060,4 @@ os.execute('sleep 1') -- Wait for things to start up before checking for them. I('Total run time was ' .. (os.time() - now) .. ' seconds.') APT.logPost() - APT.logFile:close() end -- cgit v1.1