0
0
mirror of https://github.com/Doodle3D/doodle3d-firmware.git synced 2024-12-22 02:53:49 +01:00

Add new settings key 'system.log.level' with print3d log levels.

Change uci-defaults script to make sure the new setting exists in UCI and the old one is removed.
Read new log level key in firmware and map it to firmware log level.
This commit is contained in:
Wouter R 2016-01-05 18:25:38 +01:00
parent d66d976af1
commit f51e63e06a
5 changed files with 36 additions and 5 deletions

View File

@ -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"

View File

@ -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',

View File

@ -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('^<(.*)>$')

View File

@ -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'

View File

@ -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