aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authoronefang2019-11-13 20:36:38 +1000
committeronefang2019-11-13 20:36:38 +1000
commitd2b0ff2d75f228d37f0f3d5491bfe11b134e2424 (patch)
tree98d01247a7cad44248ba69b865cbbbbaa217587b
parentClean up a nil issue. (diff)
downloadapt-panopticon-d2b0ff2d75f228d37f0f3d5491bfe11b134e2424.zip
apt-panopticon-d2b0ff2d75f228d37f0f3d5491bfe11b134e2424.tar.gz
apt-panopticon-d2b0ff2d75f228d37f0f3d5491bfe11b134e2424.tar.bz2
apt-panopticon-d2b0ff2d75f228d37f0f3d5491bfe11b134e2424.tar.xz
HTMLize the logs.
-rwxr-xr-xapt-panopticon.lua31
1 files changed, 26 insertions, 5 deletions
diff --git a/apt-panopticon.lua b/apt-panopticon.lua
index b03810c..a8796c9 100755
--- a/apt-panopticon.lua
+++ b/apt-panopticon.lua
@@ -147,6 +147,18 @@ end
147local ip = "" 147local ip = ""
148local results = {} 148local results = {}
149 149
150local logPre = function()
151 if nil ~= logFile then
152 logFile:write("<html><head>\n")
153 logFile:write("</head><body bgcolor='black' text='white' alink='red' link='blue' vlink='purple'>\n")
154 end
155end
156local logPost = function()
157 if nil ~= logFile then
158 logFile:write("</body></html> \n")
159 end
160end
161
150local log = function(v, t, s, prot, test, host) 162local log = function(v, t, s, prot, test, host)
151 local x = "" 163 local x = ""
152 if nil == prot then prot = "" end 164 if nil == prot then prot = "" end
@@ -180,7 +192,13 @@ local log = function(v, t, s, prot, test, host)
180 print(t .. ": " .. s) 192 print(t .. ": " .. s)
181 end 193 end
182 if nil ~= logFile then 194 if nil ~= logFile then
183 logFile:write(os.date() .. " " .. t .. ": " .. s .. "\n") 195 local colour = "white"
196 if -1 == v then colour = "fuchsia" end -- CRITICAL
197 if 0 == v then colour = "red " end -- ERROR
198 if 1 == v then colour = "yellow " end -- WARNING
199 if 2 == v then colour = "white " end -- INFO
200 if 3 == v then colour = "gray " end -- DEBUG
201 logFile:write(os.date() .. " <font color='" .. colour .. "'><b>" .. t .. "</b></font>: " .. s .. "</br>\n")
184 logFile:flush() 202 logFile:flush()
185 end 203 end
186end 204end
@@ -639,11 +657,12 @@ if 0 < #arg then
639 end 657 end
640 local pu = url.parse("http://" .. arg[1]) 658 local pu = url.parse("http://" .. arg[1])
641 if nil ~= arg[2] then 659 if nil ~= arg[2] then
642 logFile, e = io.open("results/" .. pu.host .. "_" .. arg[2] .. ".log", "a+") 660 logFile, e = io.open("results/LOG_" .. pu.host .. "_" .. arg[2] .. ".html", "a+")
643 else 661 else
644 logFile, e = io.open("results/" .. pu.host .. ".log", "a+") 662 logFile, e = io.open("results/LOG_" .. pu.host .. ".html", "a+")
645 end 663 end
646 if nil == logFile then C("opening log file - " .. e); return end 664 if nil == logFile then C("opening log file - " .. e); return end
665 logPre()
647 I("Starting tests for " ..arg[1] .. " with these tests - " .. table.concat(options.tests.value, ", ")) 666 I("Starting tests for " ..arg[1] .. " with these tests - " .. table.concat(options.tests.value, ", "))
648 mirrors = loadfile("results/mirrors.lua")() 667 mirrors = loadfile("results/mirrors.lua")()
649 if nil ~= arg[2] then I(" Using IP " .. arg[2]); ip = arg[2] end 668 if nil ~= arg[2] then I(" Using IP " .. arg[2]); ip = arg[2] end
@@ -677,6 +696,7 @@ if 0 < #arg then
677 else 696 else
678 checkHost(pu.host, pu.host, pu.path, arg[2], arg[3]) 697 checkHost(pu.host, pu.host, pu.path, arg[2], arg[3])
679 end 698 end
699 logPost()
680 logFile:close() 700 logFile:close()
681 local f = pu.host 701 local f = pu.host
682 if "" ~= ip then f = f .. "_" .. ip end 702 if "" ~= ip then f = f .. "_" .. ip end
@@ -693,8 +713,9 @@ else
693 end 713 end
694 os.execute("rm -f results/*.check") 714 os.execute("rm -f results/*.check")
695 os.execute("mkdir -p results; touch results/stamp") 715 os.execute("mkdir -p results; touch results/stamp")
696 logFile, e = io.open("results/apt-panopticon.log", "a+") 716 logFile, e = io.open("results/LOG_apt-panopticon.html", "a+")
697 if nil == logFile then C("opening log file - " .. e); return end 717 if nil == logFile then C("opening log file - " .. e); return end
718 logPre()
698 I("Starting tests " .. table.concat(options.tests.value, ", ")) 719 I("Starting tests " .. table.concat(options.tests.value, ", "))
699 execute("mkdir -p results") 720 execute("mkdir -p results")
700 mirrors = getMirrors() 721 mirrors = getMirrors()
@@ -731,6 +752,6 @@ else
731 execute("./" .. report .. " ") 752 execute("./" .. report .. " ")
732 end 753 end
733 end 754 end
734 755 logPost()
735 logFile:close() 756 logFile:close()
736end 757end