mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 11:03:48 +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:
parent
d66d976af1
commit
f51e63e06a
@ -77,6 +77,8 @@ $IPKG_INSTROOT/etc/init.d/wifibox start
|
|||||||
$IPKG_INSTROOT/etc/init.d/dhcpcheck enable
|
$IPKG_INSTROOT/etc/init.d/dhcpcheck enable
|
||||||
|
|
||||||
if [ -z "$IPKG_INSTROOT" ]; then
|
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..."
|
echo "Enabling and configuring wifi device..."
|
||||||
uci set wireless.@wifi-device[0].disabled=0
|
uci set wireless.@wifi-device[0].disabled=0
|
||||||
uci delete wireless.radio0.channel
|
uci delete wireless.radio0.channel
|
||||||
@ -91,9 +93,15 @@ if [ -z "$IPKG_INSTROOT" ]; then
|
|||||||
echo "Adding network interface 'wlan'..."
|
echo "Adding network interface 'wlan'..."
|
||||||
uci set network.wlan=interface
|
uci set network.wlan=interface
|
||||||
uci commit network; /etc/init.d/network reload
|
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
|
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
|
cat <<-EOM >> $IPKG_INSTROOT/etc/uci-defaults/setup-wifibox.sh
|
||||||
uci set system.@system[0].hostname=wifibox
|
uci set system.@system[0].hostname=wifibox
|
||||||
uci set system.@system[0].log_size=64
|
uci set system.@system[0].log_size=64
|
||||||
@ -109,6 +117,9 @@ else
|
|||||||
uci set network.wlan=interface
|
uci set network.wlan=interface
|
||||||
|
|
||||||
uci set dhcp.lan.dhcp_option='3 6'
|
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
|
EOM
|
||||||
|
|
||||||
echo "WARNING: WiFiBox network configuration can only be fully prepared when installing on real device"
|
echo "WARNING: WiFiBox network configuration can only be fully prepared when installing on real device"
|
||||||
|
@ -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').
|
--- 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.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 = {
|
M.network_ap_ssid = {
|
||||||
default = 'Doodle3D-%%MAC_ADDR_TAIL%%',
|
default = 'Doodle3D-%%MAC_ADDR_TAIL%%',
|
||||||
type = 'string',
|
type = 'string',
|
||||||
|
@ -128,8 +128,13 @@ local function setupLogger()
|
|||||||
local logLevel = log.LEVEL.debug -- use debug logging as hard-coded default level
|
local logLevel = log.LEVEL.debug -- use debug logging as hard-coded default level
|
||||||
|
|
||||||
local logTargetSetting = settings.getSystemKey('logfile')
|
local logTargetSetting = settings.getSystemKey('logfile')
|
||||||
local logLevelSetting = settings.getSystemKey('loglevel')
|
local logLevelSetting = settings.get('system.log.level')
|
||||||
local logTargetError, logLevelError = nil, nil
|
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
|
if type(logTargetSetting) == 'string' then
|
||||||
local specialTarget = logTargetSetting:match('^<(.*)>$')
|
local specialTarget = logTargetSetting:match('^<(.*)>$')
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
config settings 'system'
|
config settings 'system'
|
||||||
option logfile '/tmp/wifibox.log'
|
option logfile '/tmp/wifibox.log'
|
||||||
option loglevel 'debug'
|
|
||||||
|
|
||||||
config settings 'general'
|
config settings 'general'
|
||||||
option printer_type 'ultimaker'
|
option printer_type 'ultimaker'
|
||||||
|
@ -97,7 +97,7 @@ end
|
|||||||
|
|
||||||
--- Reports whether a value is valid given the constraints specified in a base table.
|
--- Reports whether a value is valid given the constraints specified in a base table.
|
||||||
-- @p value The value to test.
|
-- @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.
|
-- @treturn bool Returns true if the value is valid, false if it is not.
|
||||||
local function isValid(value, baseTable)
|
local function isValid(value, baseTable)
|
||||||
local varType, min, max, regex, isValid = baseTable.type, baseTable.min, baseTable.max, baseTable.regex, baseTable.isValid
|
local varType, min, max, regex, isValid = baseTable.type, baseTable.min, baseTable.max, baseTable.regex, baseTable.isValid
|
||||||
|
Loading…
Reference in New Issue
Block a user