diff --git a/post-install.sh b/post-install.sh index 18945a9..1ca6b1c 100644 --- a/post-install.sh +++ b/post-install.sh @@ -77,6 +77,8 @@ $IPKG_INSTROOT/etc/init.d/wifibox start $IPKG_INSTROOT/etc/init.d/dhcpcheck enable if [ -z "$IPKG_INSTROOT" ]; then + # No installation root, we are being installed on a live box so run uci commands directly. + echo "Enabling and configuring wifi device..." uci set wireless.@wifi-device[0].disabled=0 uci delete wireless.radio0.channel @@ -91,9 +93,15 @@ if [ -z "$IPKG_INSTROOT" ]; then echo "Adding network interface 'wlan'..." uci set network.wlan=interface uci commit network; /etc/init.d/network reload + + echo "Setting default wifibox log level..." + uci set wifibox.general.system_log_level='info' + uci -q delete wifibox.system.loglevel # remove key used in older versions (<=0.10.8a) if it exists + uci commit wifibox else - # Create a script to setup the system as wifibox, it will be deleted after it has been run, except if it returns > 0 + # Create a script to setup the system as wifibox, it will be deleted after it has been run, except if it returns > 0. + cat <<-EOM >> $IPKG_INSTROOT/etc/uci-defaults/setup-wifibox.sh uci set system.@system[0].hostname=wifibox uci set system.@system[0].log_size=64 @@ -109,6 +117,9 @@ else uci set network.wlan=interface uci set dhcp.lan.dhcp_option='3 6' + + uci set wifibox.general.system_log_level='info' + uci -q delete wifibox.system.loglevel # remove key used in older versions (<=0.10.8a) if it exists EOM echo "WARNING: WiFiBox network configuration can only be fully prepared when installing on real device" diff --git a/src/conf_defaults.lua b/src/conf_defaults.lua index 6369cee..09dbb5c 100644 --- a/src/conf_defaults.lua +++ b/src/conf_defaults.lua @@ -44,6 +44,22 @@ M.API_INCLUDE_ENDPOINT_INFO = false --- This base path is used in @{rest.response}. It includes any base path if necessary (e.g. 'localhost/~user'). M.API_BASE_URL_PATH = 'doodle3d.com' +M.system_log_level = { + default = 'info', + type = 'string', + description = 'Log level for firmware and print server', + isValid = function(value) + -- Note: level names mimic those in print3d + levelNames = { 'quiet', 'error', 'warning', 'info', 'verbose', 'bulk' } + for i,v in ipairs(levelNames) do + if value == v then + return true + end + end + return false, 'not one of '..table.concat(levelNames, ',') + end +} + M.network_ap_ssid = { default = 'Doodle3D-%%MAC_ADDR_TAIL%%', type = 'string', diff --git a/src/main.lua b/src/main.lua index 12260cd..538687e 100644 --- a/src/main.lua +++ b/src/main.lua @@ -128,8 +128,13 @@ local function setupLogger() local logLevel = log.LEVEL.debug -- use debug logging as hard-coded default level local logTargetSetting = settings.getSystemKey('logfile') - local logLevelSetting = settings.getSystemKey('loglevel') + local logLevelSetting = settings.get('system.log.level') local logTargetError, logLevelError = nil, nil + + -- TEMP: for now, translate print3d log level to firmware level, these will be unfiied in the future + -- we get (print3d): quiet,error,warning,info,verbose,bulk -- and we need (firmware): debug,info,warn,error,fatal + logLevelMapping = { quiet='fatal', error='error', warning='warn', info='info', verbose='info', bulk='debug' } + logLevelSetting = logLevelMapping[logLevelSetting] if type(logTargetSetting) == 'string' then local specialTarget = logTargetSetting:match('^<(.*)>$') diff --git a/src/script/wifibox.uci.config b/src/script/wifibox.uci.config index c1c4bab..0194e07 100644 --- a/src/script/wifibox.uci.config +++ b/src/script/wifibox.uci.config @@ -1,6 +1,5 @@ config settings 'system' - option logfile '/tmp/wifibox.log' - option loglevel 'debug' + option logfile '/tmp/wifibox.log' config settings 'general' option printer_type 'ultimaker' diff --git a/src/util/settings.lua b/src/util/settings.lua index 52c52d5..a01693e 100644 --- a/src/util/settings.lua +++ b/src/util/settings.lua @@ -97,7 +97,7 @@ end --- Reports whether a value is valid given the constraints specified in a base table. -- @p value The value to test. --- @tab baseTable The base table to use constraint data from (min,max,regex). +-- @tab baseTable The base table to use constraint data from (min,max,regex,isValid). -- @treturn bool Returns true if the value is valid, false if it is not. local function isValid(value, baseTable) local varType, min, max, regex, isValid = baseTable.type, baseTable.min, baseTable.max, baseTable.regex, baseTable.isValid