diff --git a/src/main.lua b/src/main.lua index c481a2b..368b284 100644 --- a/src/main.lua +++ b/src/main.lua @@ -227,31 +227,32 @@ local function main(environment) local version = updater.formatVersion(updater.getCurrentVersion()); log:info(MOD_ABBR, "Doodle3D version: "..util.dump(version)) - log:info(MOD_ABBR, "running in autowifi mode") + log:info(MOD_ABBR, "Running in autowifi mode") local rv,msg = setupAutoWifiMode() if rv then - log:info(MOD_ABBR, "autowifi setup done (" .. msg .. ")") + log:info(MOD_ABBR, "Autowifi setup done (" .. msg .. ")") else - log:error(MOD_ABBR, "autowifi setup failed (" .. msg .. ")") + log:error(MOD_ABBR, "Autowifi setup failed (" .. msg .. ")") end elseif rq:getRequestMethod() == 'CMDLINE' and rq:get('signin') ~= nil then - log:info(MOD_ABBR, "running in signin mode") + log:info(MOD_ABBR, "Running in signin mode") local ds = wifi.getDeviceState() - log:info(MOD_ABBR, " ds.mode: "..util.dump(ds.mode)) + log:info(MOD_ABBR, " wifi deviceState.mode: "..util.dump(ds.mode)) if ds.mode == "sta" then log:info(MOD_ABBR, " attempting signin") local success,msg = Signin.signin() if success then log:info(MOD_ABBR, "Signin successful") else - log:info(MOD_ABBR, "Signin failed: "..util.dump(msg)) + log:warning(MOD_ABBR, "Signin failed: "..util.dump(msg)) end end elseif rq:getRequestMethod() ~= 'CMDLINE' or confDefaults.DEBUG_API then - -- log:info(MOD_ABBR, "received request of type " .. rq:getRequestMethod() .. " for " .. (rq:getRequestedApiModule() or "") - -- .. "/" .. (rq:getRealApiFunctionName() or "") .. " with arguments: " .. util.dump(rq:getAll())) + -- Note: the commented log statement will print too many data if it's for instance dumping a gcode add request + --log:info(MOD_ABBR, "received request of type " .. rq:getRequestMethod() .. " for " .. (rq:getRequestedApiModule() or "") + -- .. "/" .. (rq:getRealApiFunctionName() or "") .. " with arguments: " .. util.dump(rq:getAll())) log:info(MOD_ABBR, "received request of type " .. rq:getRequestMethod() .. " for " .. (rq:getRequestedApiModule() or "") .. "/" .. (rq:getRealApiFunctionName() or "")) if rq:getRequestMethod() ~= 'CMDLINE' then @@ -287,7 +288,7 @@ function handle_request(env) resp:setError("initialization failed" .. errSuffix) resp:send() - log:error(MOD_ABBR, "initialization failed" .. errSuffix) --NOTE: this assumes the logger has been initialized properly, despite init() having failed + log:error(MOD_ABBR, "Initialization failed" .. errSuffix) --NOTE: this assumes the logger has been initialized properly, despite init() having failed return 1 else diff --git a/src/network/netconfig.lua b/src/network/netconfig.lua index 14fe69b..7863377 100644 --- a/src/network/netconfig.lua +++ b/src/network/netconfig.lua @@ -64,7 +64,7 @@ function M.switchConfiguration(components) for k,v in pairs(components) do local fname = k .. '_' .. v if type(reconf[fname]) == 'function' then - log:verbose(MOD_ABBR, "reconfiguring component '" .. k .. "' (" .. v .. ")") + log:info(MOD_ABBR, "reconfiguring component '" .. k .. "' (" .. v .. ")") reconf[fname](dirtyList) else log:warning(MOD_ABBR, "unknown component or action '" .. fname .. "' skipped") @@ -94,7 +94,7 @@ function M.reloadComponent(c, silent) os.execute(cmd) else rv = utils.captureCommandOutput(cmd) - log:verbose(MOD_ABBR, " result reloading component '" .. c .. "' (cmd: '"..cmd.."'): \n"..utils.dump(rv)) + log:info(MOD_ABBR, " result reloading component '" .. c .. "' (cmd: '"..cmd.."'): \n"..utils.dump(rv)) end end @@ -215,7 +215,7 @@ function reconf.dnsredir_add(dirtyList) local redirText = '/#/' .. settings.get('network.ap.address') local sname = utils.getUciSectionName('dhcp', 'dnsmasq') if sname == nil then return log:error(MOD_ABBR, "dhcp config does not contain a dnsmasq section") end - if uci:get('dhcp', sname, 'address') ~= nil then return log:verbose(MOD_ABBR, "DNS address redirection already in place, not re-adding", false) end + if uci:get('dhcp', sname, 'address') ~= nil then return log:info(MOD_ABBR, "DNS address redirection already in place, not re-adding", false) end uci:set('dhcp', sname, 'address', {redirText}) commitBit(dirtyList, 'dhcp'); reloadBit(dirtyList, 'dnsmasq') @@ -232,7 +232,7 @@ end --TODO: handle os.rename() return values (nil+msg on error) function reconf.wwwcaptive_add(dirtyList) if utils.exists(M.WWW_CAPTIVE_INDICATOR) then - return log:verbose(MOD_ABBR, "WWW captive directory already in place, not redoing", false) + return log:info(MOD_ABBR, "WWW captive directory already in place, not redoing", false) end local rv,reason = os.rename('/www', M.WWW_RENAME_NAME) if rv == true then @@ -243,7 +243,7 @@ function reconf.wwwcaptive_add(dirtyList) end end function reconf.wwwcaptive_rm(dirtyList) - if not utils.exists(M.WWW_CAPTIVE_INDICATOR) then return log:verbose(MOD_ABBR, "WWW captive directory not in place, not undoing", false) end + if not utils.exists(M.WWW_CAPTIVE_INDICATOR) then return log:info(MOD_ABBR, "WWW captive directory not in place, not undoing", false) end os.remove('/www') if os.rename(M.WWW_RENAME_NAME, '/www') ~= true then return log:error(MOD_ABBR, "Could not rename " .. M.WWW_RENAME_NAME .. " to /www") @@ -290,7 +290,8 @@ function M.setupAccessPoint(ssid) local ds = wifi.getDeviceState() --log:info(MOD_ABBR, " network/status: ") log:info(MOD_ABBR, " ssid: ".. utils.dump(ds.ssid)) - --[[log:info(MOD_ABBR, " bssid: ".. utils.dump(ds.bssid)) + --[[ + log:info(MOD_ABBR, " bssid: ".. utils.dump(ds.bssid)) log:info(MOD_ABBR, " channel: ".. utils.dump(ds.channel)) log:info(MOD_ABBR, " mode: ".. utils.dump(ds.mode)) log:info(MOD_ABBR, " encryption: ".. utils.dump(ds.encryption)) @@ -302,7 +303,8 @@ function M.setupAccessPoint(ssid) log:info(MOD_ABBR, " raw: ".. utils.dump(ds)) local localip = wifi.getLocalIP() - log:info(MOD_ABBR, " localip: "..utils.dump(localip))]]-- + log:info(MOD_ABBR, " localip: "..utils.dump(localip)) + --]] return true end @@ -313,13 +315,13 @@ end -- @tparam string ssid The SSID to use for the access point. -- @return True on success or nil+msg on error. function M.enableAccessPoint(ssid) - log:verbose(MOD_ABBR, "enableAccessPoint ssid: ".. utils.dump(ssid)) + log:info(MOD_ABBR, "enableAccessPoint ssid: ".. utils.dump(ssid)) M.switchConfiguration{apnet="add_noreload"} wifi.activateConfig(ssid) local ds = wifi.getDeviceState() - log:verbose(MOD_ABBR, " ssid: ".. utils.dump(ds.ssid)) + log:info(MOD_ABBR, " deviceState.ssid: ".. utils.dump(ds.ssid)) return true end @@ -392,6 +394,7 @@ function M.associateSsid(ssid, passphrase, recreate) end end end + log:info(MOD_ABBR, "Network associated") -- signin to connect.doodle3d.com local success, output = signin.signin() @@ -426,11 +429,9 @@ function M.getStatus() return "","" else local status = file:read('*a') - --log:info(MOD_ABBR, " status: "..utils.dump(status)) file:close() local code, msg = string.match(status, '([^|]+)|+(.*)') - --log:info(MOD_ABBR, " code: "..utils.dump(code)) - --log:info(MOD_ABBR, " msg: "..utils.dump(msg)) + log:verbose(MOD_ABBR, " raw status: "..utils.dump(status).." (code: "..utils.dump(code)..", msg: "..utils.dump(msg)..")") return code,msg end end diff --git a/src/network/signin.lua b/src/network/signin.lua index 6d8a8cf..6576d95 100644 --- a/src/network/signin.lua +++ b/src/network/signin.lua @@ -54,7 +54,7 @@ function M.signin() local signinResponse = "" while true do if os.time() > nextAttemptTime then - log:verbose(MOD_ABBR, "signin attempt "..utils.dump(attempt).."/"..utils.dump(maxAttempts)) + log:verbose(MOD_ABBR, " signin attempt "..utils.dump(attempt).."/"..utils.dump(maxAttempts)) local signedin = false local localip = wifi.getLocalIP(); --log:verbose(MOD_ABBR, " localip: "..utils.dump(localip)) @@ -71,10 +71,10 @@ function M.signin() if success ~= nil then signedin = true else - log:warning(MOD_ABBR, "signin failed request failed (response: "..utils.dump(signinResponse)..")") + log:warning(MOD_ABBR, "signin failed, request failed (response: "..utils.dump(signinResponse)..")") end else - log:warning(MOD_ABBR, "signin failed no local ip found (attempt: "..utils.dump(attempt).."/"..utils.dump(maxAttempts)..")") + log:warning(MOD_ABBR, "signin failed, no local ip found (attempt: "..utils.dump(attempt).."/"..utils.dump(maxAttempts)..")") end if signedin then diff --git a/src/network/wlanconfig.lua b/src/network/wlanconfig.lua index 0a63573..39f7fd3 100644 --- a/src/network/wlanconfig.lua +++ b/src/network/wlanconfig.lua @@ -128,7 +128,7 @@ end --returns the wireless local ip address function M.getLocalIP() local ifconfig, rv = utils.captureCommandOutput("ifconfig wlan0"); - --log:verbose(MOD_ABBR, " ifconfig: \n"..utils.dump(ifconfig)); + log:bulk(MOD_ABBR, " ifconfig: \n"..utils.dump(ifconfig)); local localip = ifconfig:match('inet addr:([%d%.]+)') return localip @@ -189,12 +189,12 @@ end --- Activate wireless section for given SSID and disable all others -- @param ssid SSID of config to enable, or nil to disable all network configs function M.activateConfig(ssid) - --log:info(MOD_ABBR, "wlanconfig.activateConfig: "..ssid); + log:verbose(MOD_ABBR, "wlanconfig.activateConfig: "..ssid); -- make sure only one is enabled uci:foreach('wireless', 'wifi-iface', function(s) local disabled = s.ssid ~= ssid and '1' or '0' - --log:info(MOD_ABBR, " "..utils.dump(s.ssid).." disable: "..utils.dump(disabled)) + log:verbose(MOD_ABBR, " ssid: "..utils.dump(s.ssid).." disabled: "..utils.dump(disabled)) uci:set('wireless', s['.name'], 'disabled', disabled) end) @@ -212,11 +212,14 @@ function M.activateConfig(ssid) return false end end) - --[[log:info(MOD_ABBR, " result:"); + + --[[ + log:verbose(MOD_ABBR, " wifi reorder result:"); uci:foreach('wireless', 'wifi-iface', function(s) local disabled = s.ssid ~= ssid and '1' or '0' - log:info(MOD_ABBR, " "..utils.dump(s.ssid).." disable: "..utils.dump(disabled)) - end)]]-- + log:verbose(MOD_ABBR, " ssid: "..utils.dump(s.ssid).." disabled: "..utils.dump(disabled)) + end) + --]] uci:commit('wireless') end diff --git a/src/rest/api/api_config.lua b/src/rest/api/api_config.lua index 9527919..45de490 100644 --- a/src/rest/api/api_config.lua +++ b/src/rest/api/api_config.lua @@ -59,7 +59,7 @@ end -- returns substituted_wifiboxid (since version 0.10.2) -- returns substituted_ssid (since version 0.9.1) function M._global_POST(request, response) - --log:info(MOD_ABBR, "API:config:set") + log:verbose(MOD_ABBR, "API:config(set)") if not operationsAccessOrFail(request, response) then return end @@ -67,14 +67,14 @@ function M._global_POST(request, response) local validation = {} for k,v in pairs(request:getAll()) do - --log:info(MOD_ABBR, " "..k..": "..v); + log:verbose(MOD_ABBR, " about to set '"..k.."' -> '"..v.."'"); local r,m = settings.set(k, v, true) if r then validation[k] = "ok" elseif r == false then validation[k] = "could not save setting ('" .. m .. "')" - log:info(MOD_ABBR, " m: "..utils.dump(m)) + log:info(MOD_ABBR, " failed to set '"..k.."' ("..utils.dump(m)..")") elseif r == nil then settings.commit() response:setError(m) @@ -111,7 +111,7 @@ end -- and printer.type is set to 'ultimaker' then -- only the printer.startcode under the ultimaker subsection is removed. function M.reset_POST(request, response) - --log:info(MOD_ABBR, "API:reset"); + --log:verbose(MOD_ABBR, "API:config/reset") if not operationsAccessOrFail(request, response) then return end response:setSuccess() @@ -120,9 +120,11 @@ function M.reset_POST(request, response) local r,m = settings.reset(k); if r ~= nil then response:addData(k, "ok") + log:verbose(MOD_ABBR, " reset " .. k) else response:addData(k, "could not reset key ('" .. m .. "')") response:setError(m) + log:verbose(MOD_ABBR, " could not reset key " .. k .. "(" .. m .. ")") return end end diff --git a/src/rest/api/api_network.lua b/src/rest/api/api_network.lua index 4e234bc..c34c697 100644 --- a/src/rest/api/api_network.lua +++ b/src/rest/api/api_network.lua @@ -203,14 +203,14 @@ function M.remove_POST(request, response) end function M.signin(request, response) - log:info(MOD_ABBR, "API:Network:signin") + log:info(MOD_ABBR, "API:network/signin") local success, output = signin.signin() if success then - log:info(MOD_ABBR, "API:Network:signed in") + log:info(MOD_ABBR, " signed in") response:setSuccess("API:Network:signed in") response:addData("response", output) else - log:info(MOD_ABBR, "API:Network:Signing in failed") + log:info(MOD_ABBR, "signing in failed") response:setError("Signing in failed") end end diff --git a/src/rest/api/api_printer.lua b/src/rest/api/api_printer.lua index c90c542..9fc693b 100644 --- a/src/rest/api/api_printer.lua +++ b/src/rest/api/api_printer.lua @@ -166,6 +166,7 @@ end --accepts: first(bool) (chunks will be concatenated but output file will be cleared first if this argument is true) --accepts: start(bool) (only when this argument is true will printing be started) function M.print_POST(request, response) + log:info(MOD_ABBR, "API:printer/print") local controllerIP = accessManager.getController() local hasControl = false @@ -198,7 +199,7 @@ function M.print_POST(request, response) end if argIsFirst == true then - log:verbose(MOD_ABBR, "clearing all gcode for " .. printer:getId()) + log:verbose(MOD_ABBR, " clearing all gcode for " .. printer:getId()) response:addData('gcode_clear',true) local rv,msg = printer:clearGcode() diff --git a/src/rest/api/api_sketch.lua b/src/rest/api/api_sketch.lua index ae71ce2..1cb32c8 100644 --- a/src/rest/api/api_sketch.lua +++ b/src/rest/api/api_sketch.lua @@ -31,7 +31,7 @@ local SKETCH_FILE_EXTENSION = 'svg' -- creates sketch directory, and sets response to error state on failure local function createSketchDirectory() if os.execute('mkdir -p ' .. M.SKETCH_DIR) ~= 0 then - log:error(MOD_ABBR, "Error: could not create sketch directory '" .. M.SKETCH_DIR .. "'") + log:error(MOD_ABBR, "could not create sketch directory '" .. M.SKETCH_DIR .. "'") response:setError("could not create sketch directory") return false end