From f78da3880ca3afe1d3243da165e7941f32bc9ea7 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 25 Jun 2019 21:46:43 +1000 Subject: Make logging work. I really should test things better before comitting them --- mirror-checker.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mirror-checker.lua b/mirror-checker.lua index cd7cc3d..4ebaecb 100755 --- a/mirror-checker.lua +++ b/mirror-checker.lua @@ -63,7 +63,7 @@ local referenceDebs = } local arg = {} local sendArgs = "" -local log +local logFile local socket = require 'socket' @@ -106,9 +106,9 @@ local log = function(v, t, s) if 3 <= verbosity then t = os.date() .. " " .. t end print(t .. ": " .. s) end - if nil ~= log then - log:write(os.date() .. " " .. t .. ": " .. s .. "/n") - log:flush() + if nil ~= logFile then + logFile:write(os.date() .. " " .. t .. ": " .. s .. "/n") + logFile:flush() end end local D = function(s) log(3, "DEBUG ", s) end @@ -380,10 +380,10 @@ end execute("mkdir -p results") if 0 < #arg then - if nil ~= arg[2] - log = io.open ("mirror-checker-lua_" .. arg[1] .. "_" .. arg[2] .. ".log", "a+") + if nil ~= arg[2] then + logFile = io.open ("results/mirror-checker-lua_" .. arg[1] .. "_" .. arg[2] .. ".log", "a+") else - log = io.open ("mirror-checker-lua_" .. arg[1] .. ".log", "a+" [, mode]) + logFile = io.open ("results/mirror-checker-lua_" .. arg[1] .. ".log", "a+") end local pu = url.parse("http://" .. arg[1], defaultURL) I("Starting tests for " ..pu.host .. " with these tests - " .. table.concat(options.tests.value, ", ")) @@ -397,7 +397,7 @@ if 0 < #arg then checkHost(pu.host, pu.path, arg[2]) else if not keep then os.execute("rm -f results/*.log") end - log = io.open ("mirror-checker-lua.log", "a+") + logFile = io.open ("results/mirror-checker-lua.log", "a+") I("Starting tests " .. table.concat(options.tests.value, ", ")) execute("mkdir -p results") local mirrors = getMirrors() -- cgit v1.1