From f8798ecc46df2f17c294210203ad7ce0bdec86b2 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 5 Nov 2019 21:05:29 +1000 Subject: Tidy up some loose ends with "test name and host included on log lines". --- apt-panopticon.lua | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/apt-panopticon.lua b/apt-panopticon.lua index 84a6bed..e1a481f 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua @@ -151,19 +151,26 @@ local results = {} local log = function(v, t, s, prot, test, host) local x = "" if nil == prot then prot = "" end - if nil ~= test then x = x .. test else test = "" end + if nil == test then test = "" end + x = x .. prot + if "" ~= test then + if #x > 0 then x = x .. " " end + x = x .. test + end if nil ~= host then if #x > 0 then x = x .. " " end x = x .. host end if #x > 0 then t = t .. "(" .. x .. ")" - if "" == test then - if v == 0 then results[prot].errors = results[prot].errors + 1 end - if v == 1 then results[prot].warnings = results[prot].warnings + 1 end - else - if v == 0 then results[prot][test].errors = results[prot][test].errors + 1 end - if v == 1 then results[prot][test].warnings = results[prot][test].warnings + 1 end + if "" ~= prot then + if "" == test then + if v == 0 then results[prot].errors = results[prot].errors + 1 end + if v == 1 then results[prot].warnings = results[prot].warnings + 1 end + else + if v == 0 then results[prot][test].errors = results[prot][test].errors + 1 end + if v == 1 then results[prot][test].warnings = results[prot][test].warnings + 1 end + end end end if v <= verbosity then @@ -304,7 +311,7 @@ checkHEAD = function (host, URL, r, retry) end if l == URL then - E(" redirect loop! " .. check .. " " .. host .. " -> " .. URL, PU.scheme, PU.scheme, host) + E(" redirect loop! " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "", host) elseif nil == pu.host then I(" relative redirect. " .. check .. " " .. host .. " -> " .. URL .. " -> " .. l) checkHEAD(host, PU.scheme .. "://" .. PU.host .. l, r + 1) @@ -459,7 +466,7 @@ local getMirrors = function () end m[t] = prot elseif "Active" == t and nil == d:find("yes", 1, true) then - W("Mirror " .. host .. " is not active - " .. d) + W("Mirror " .. host .. " is not active - " .. d, "", "", host) active = false -- TODO - Should do some input validation on BaseURL, and everything else. else @@ -627,11 +634,11 @@ else checkHost(options.referenceSite.value) for k, m in pairs(mirrors) do if "/" == m.BaseURL:sub(-1, -1) then - W("slash at end of BaseURL in mirror_list.txt! " .. m.BaseURL) + W("slash at end of BaseURL in mirror_list.txt! " .. m.BaseURL, "", "", m.FQDN) m.BaseURL = m.BaseURL:sub(1, -2) end if " " == m.BaseURL:sub(-1, -1) then - W("space at end of BaseURL in mirror_list.txt! " .. m.BaseURL) + W("space at end of BaseURL in mirror_list.txt! " .. m.BaseURL, "", "", m.FQDN) m.BaseURL = m.BaseURL:sub(1, -2) end local pu = url.parse("http://" .. m.BaseURL) -- cgit v1.1