From aa8f2cef4153658baeecdcdb3213d5b4a9cd07f2 Mon Sep 17 00:00:00 2001 From: Andrey Petelin Date: Wed, 10 Dec 2025 17:58:22 +0500 Subject: [PATCH] feat: Add log_level option in LuCI and use configured value for sing-box logging --- .../resources/view/podkop/settings.js | 18 ++++++++++++++++++ podkop/files/etc/config/podkop | 1 + podkop/files/usr/bin/podkop | 4 +++- podkop/files/usr/lib/constants.sh | 2 -- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/settings.js b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/settings.js index 7dd8f20..6c89ed3 100644 --- a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/settings.js +++ b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/settings.js @@ -378,6 +378,24 @@ function createSettingsContent(section) { return true; }; + o = section.option( + form.ListValue, + "log_level", + _("Log Level"), + _( + "Select the log level for sing-box", + ), + ); + o.value("trace", "Trace"); + o.value("debug", "Debug"); + o.value("info", "Info"); + o.value("warn", "Warn"); + o.value("error", "Error"); + o.value("fatal", "Fatal"); + o.value("panic", "Panic"); + o.default = "warn"; + o.rmempty = false; + o = section.option( form.Flag, "exclude_ntp", diff --git a/podkop/files/etc/config/podkop b/podkop/files/etc/config/podkop index f7224fb..130b354 100644 --- a/podkop/files/etc/config/podkop +++ b/podkop/files/etc/config/podkop @@ -16,6 +16,7 @@ config settings 'settings' option dont_touch_dhcp '0' option config_path '/etc/sing-box/config.json' option cache_path '/tmp/sing-box/cache.db' + option log_level 'warn' option exclude_ntp '0' option shutdown_correctly '0' #list routing_excluded_ips '192.168.1.3' diff --git a/podkop/files/usr/bin/podkop b/podkop/files/usr/bin/podkop index f0fbb0f..bcf243b 100755 --- a/podkop/files/usr/bin/podkop +++ b/podkop/files/usr/bin/podkop @@ -590,7 +590,9 @@ sing_box_init_config() { sing_box_configure_log() { log "Configure the log section of a sing-box JSON configuration" - config=$(sing_box_cm_configure_log "$config" false "$SB_DEFAULT_LOG_LEVEL" false) + local log_level + config_get log_level "settings" "log_level" + config=$(sing_box_cm_configure_log "$config" false "$log_level" false) } sing_box_configure_inbounds() { diff --git a/podkop/files/usr/lib/constants.sh b/podkop/files/usr/lib/constants.sh index 2d2612f..4c6a490 100644 --- a/podkop/files/usr/lib/constants.sh +++ b/podkop/files/usr/lib/constants.sh @@ -22,8 +22,6 @@ NFT_INTERFACE_SET_NAME="interfaces" ## sing-box SB_REQUIRED_VERSION="1.12.0" -# Log -SB_DEFAULT_LOG_LEVEL="warn" # DNS SB_DNS_SERVER_TAG="dns-server" SB_FAKEIP_DNS_SERVER_TAG="fakeip-server"