diff options
author | onefang | 2019-06-25 22:22:55 +1000 |
---|---|---|
committer | onefang | 2019-06-25 22:22:55 +1000 |
commit | c2a115c27cac281a659c657014dde6c93c7566e1 (patch) | |
tree | 54b6cfb27fd140576b19e7786ac0d22343e809f1 | |
parent | Modify printTable to look more like an actual table definition. (diff) | |
download | apt-panopticon-c2a115c27cac281a659c657014dde6c93c7566e1.zip apt-panopticon-c2a115c27cac281a659c657014dde6c93c7566e1.tar.gz apt-panopticon-c2a115c27cac281a659c657014dde6c93c7566e1.tar.bz2 apt-panopticon-c2a115c27cac281a659c657014dde6c93c7566e1.tar.xz |
More fixes of the logging.
Typo--
Use the base host name for the log file name, not the host/path.
Actually check the open file return code.
Close the log file at the end, though not really needed, coz Lua will
close it at GC time.
-rwxr-xr-x | mirror-checker.lua | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/mirror-checker.lua b/mirror-checker.lua index c9dd870..cd95135 100755 --- a/mirror-checker.lua +++ b/mirror-checker.lua | |||
@@ -108,7 +108,7 @@ local log = function(v, t, s) | |||
108 | print(t .. ": " .. s) | 108 | print(t .. ": " .. s) |
109 | end | 109 | end |
110 | if nil ~= logFile then | 110 | if nil ~= logFile then |
111 | logFile:write(os.date() .. " " .. t .. ": " .. s .. "/n") | 111 | logFile:write(os.date() .. " " .. t .. ": " .. s .. "\n") |
112 | logFile:flush() | 112 | logFile:flush() |
113 | end | 113 | end |
114 | end | 114 | end |
@@ -381,12 +381,13 @@ end | |||
381 | execute("mkdir -p results") | 381 | execute("mkdir -p results") |
382 | 382 | ||
383 | if 0 < #arg then | 383 | if 0 < #arg then |
384 | local pu = url.parse("http://" .. arg[1], defaultURL) | ||
384 | if nil ~= arg[2] then | 385 | if nil ~= arg[2] then |
385 | logFile = io.open ("results/mirror-checker-lua_" .. arg[1] .. "_" .. arg[2] .. ".log", "a+") | 386 | logFile, e = io.open("results/mirror-checker-lua_" .. pu.host .. "_" .. arg[2] .. ".log", "a+") |
386 | else | 387 | else |
387 | logFile = io.open ("results/mirror-checker-lua_" .. arg[1] .. ".log", "a+") | 388 | logFile, e = io.open("results/mirror-checker-lua_" .. pu.host .. ".log", "a+") |
388 | end | 389 | end |
389 | local pu = url.parse("http://" .. arg[1], defaultURL) | 390 | if nil == logFile then C("opening log file - " .. e) end |
390 | I("Starting tests for " ..pu.host .. " with these tests - " .. table.concat(options.tests.value, ", ")) | 391 | I("Starting tests for " ..pu.host .. " with these tests - " .. table.concat(options.tests.value, ", ")) |
391 | if nil ~= arg[2] then I(" Using IP " .. arg[2]) end | 392 | if nil ~= arg[2] then I(" Using IP " .. arg[2]) end |
392 | if testing("Integrity") or testing("Updated") then | 393 | if testing("Integrity") or testing("Updated") then |
@@ -396,9 +397,11 @@ if 0 < #arg then | |||
396 | checkExes(download) | 397 | checkExes(download) |
397 | end | 398 | end |
398 | checkHost(pu.host, pu.path, arg[2]) | 399 | checkHost(pu.host, pu.path, arg[2]) |
400 | logFile:close() | ||
399 | else | 401 | else |
400 | if not keep then os.execute("rm -f results/*.log") end | 402 | if not keep then os.execute("rm -f results/*.log") end |
401 | logFile = io.open ("results/mirror-checker-lua.log", "a+") | 403 | logFile, e = io.open("results/mirror-checker-lua.log", "a+") |
404 | if nil == logFile then C("opening log file - " .. e) end | ||
402 | I("Starting tests " .. table.concat(options.tests.value, ", ")) | 405 | I("Starting tests " .. table.concat(options.tests.value, ", ")) |
403 | execute("mkdir -p results") | 406 | execute("mkdir -p results") |
404 | local mirrors = getMirrors() | 407 | local mirrors = getMirrors() |
@@ -418,4 +421,5 @@ else | |||
418 | if testing("Integrity") or testing("Updated") then | 421 | if testing("Integrity") or testing("Updated") then |
419 | while 1 < checkExes(download) do os.execute("sleep 30") end | 422 | while 1 < checkExes(download) do os.execute("sleep 30") end |
420 | end | 423 | end |
424 | logFile:close() | ||
421 | end | 425 | end |