feat: enhance logging configuration and add translations for display lines

This commit is contained in:
SunBK201 2025-11-02 06:04:03 +08:00
parent 75d5af5b03
commit cc95016747
5 changed files with 41 additions and 7 deletions

View File

@ -7,5 +7,5 @@ License: GPL-3.0-only
Section: net
SourceDateEpoch: 1711267200
Architecture: all
Installed-Size: 4362240
Installed-Size: 4372480
Description: Advanced HTTP User-Agent Rewriting Tool.

View File

@ -7,5 +7,5 @@ License: GPL-3.0-only
Section: net
SourceDateEpoch: 1711267200
Architecture: all
Installed-Size: 4362240
Installed-Size: 4372480
Description: Advanced HTTP User-Agent Rewriting Tool.

View File

@ -50,9 +50,12 @@ log_level:value("warn")
log_level:value("error")
log_level:value("fatal")
log_level:value("panic")
log_level.description = translate(
"Sets the logging level. Do not keep the log level set to debug/info/warn for an extended period of time.")
ua = general:taboption("general", Value, "ua", translate("User-Agent"))
ua.placeholder = "FFF"
ua.description = translate("User-Agent to be rewritten")
uaRegexPattern = general:taboption("general", Value, "ua_regex", translate("User-Agent Regex Pattern"))
uaRegexPattern.description = translate("Regular expression pattern for matching User-Agent")
@ -62,12 +65,37 @@ partialRepalce.description =
translate("Replace only the matched part of the User-Agent, only works when User-Agent Regex Pattern is not empty")
partialRepalce.default = "0"
log = general:taboption("log", TextValue, "")
log = general:taboption("log", TextValue, "log")
log.readonly = true
log.cfgvalue = function(self, section)
return luci.sys.exec("cat /var/log/ua3f/ua3f.log")
end
log.rows = 30
function log.cfgvalue(self, section)
local logfile = "/var/log/ua3f/ua3f.log"
local fs = require("nixio.fs")
if not fs.access(logfile) then
return ""
end
local n = tonumber(luci.model.uci.cursor():get("ua3f", section, "log_lines")) or 1000
return luci.sys.exec("tail -n " .. n .. " " .. logfile)
end
function log.write(self, section, value) end
function log.render(self, section, scope)
TextValue.render(self, section, scope)
luci.http.write("<script>")
luci.http.write([[
var textarea = document.getElementById('cbid.ua3f.main.log');
if (textarea) {
textarea.scrollTop = textarea.scrollHeight;
}
]])
luci.http.write("</script>")
end
logLines = general:taboption("log", Value, "log_lines", translate("Display Lines"))
logLines.default = "1000"
logLines.datatype = "uinteger"
logLines.rmempty = false
stats = general:taboption("stats", DummyValue, "")
stats.template = "ua3f/statistics"

View File

@ -8,4 +8,4 @@ config 'ua3f' 'main'
option ua 'FFF'
option ua_regex '(Apple|iPhone|iPad|Macintosh|Mac OS X|Mac|Darwin|Microsoft|Windows|Linux|Android|OpenHarmony|HUAWEI|OPPO|Vivo|XiaoMi|Mobile|Dalvik)'
option partial_replace false
option log_level 'info'
option log_level 'error'

View File

@ -76,3 +76,9 @@ msgstr "放行次数"
msgid "Last Host"
msgstr "最后访问地址"
msgid "Display Lines"
msgstr "显示行数"
msgid "Sets the logging level. Do not keep the log level set to debug/info/warn for an extended period of time."
msgstr "设置日志级别,请勿长时间将日志级别设置为 debug / info / warn"