Openwrt21.02应用日志全局开关控制

在部署好的Openwrt系统上实现自定义应用日志的全局开关控制

Openwrt系统本身有系统日志、内核日志,应用日志默认会写入系统日志中,但是用户可以通过修改配置文件来关闭应用日志写入系统日志。通过Luci界面开发,提供一个开关,用户可以控制自定义应用日志是否写入系统日志。但一些 sshd、kernel 或其他系统日志仍会写入。

步骤1:创建全局UCI配置文件

bash 复制代码
cat << "EOF" > /etc/config/luci_global_log
config global 'settings'
    option enable '1'      # 1启用,0禁用,默认启用
    option log_level 'info'  # 日志级别,可选值:info, debug, warning, err, crit
EOF

步骤2:创建全局日志管理模块

lua 复制代码
-- luci\lua\luci\log_switch.lua
module("luci.log_switch", package.seeall)

local uci = require "luci.model.uci"


-- 读取全局开关状态(带缓存,避免每次读UCI)
local _cache = nil
function is_log_enabled()
    if _cache == nil then
        local cursor = uci.cursor()
        local enabled = cursor:get("luci_global_log", "settings", "enable") or "1"
        _cache = (enabled == "1")
    end
    return _cache
end

-- 清除缓存(当通过UCI修改配置后需要调用)
function clear_cache()
    _cache = nil
end

-- 关键的"猴子补丁":重写 nixio.syslog
local original_syslog = nixio.syslog
function patched_syslog(level, message)
    original_syslog("info", "[LogSwitch]:" ..tostring(is_log_enabled()))
    if is_log_enabled() then
        return original_syslog(level, message)
    end
    -- 如果日志被禁用,则静默丢弃日志消息
    return true -- 模拟成功调用
end

-- 提供一个函数来应用或移除补丁
function apply_patch()
    nixio.syslog = patched_syslog
    original_syslog("info", "LuCI全局日志补丁已应用,日志功能已" .. (is_log_enabled() and "启用" or "禁用"))
    original_syslog("info", "original_syslog==nixio.syslog:" ..tostring(original_syslog == nixio.syslog) )

end

function remove_patch()
    if original_syslog then
        nixio.syslog = original_syslog
        original_syslog("info", "LuCI全局日志补丁已移除")
    end
end

步骤3:在Luci初始化时加载并应用补丁

bash 复制代码
cat << "EOF" >> /etc/rc.local
# 等待系统服务就绪
sleep 5
# 加载并应用日志补丁
lua -e '
local ok, ls = pcall(require, "luci.log_switch")
if ok then
    ls.apply_patch()
    os.execute("logger -t luci-log-patch \"全局日志补丁在启动时应用成功\"")
else
    os.execute("logger -t luci-log-patch \"加载日志补丁模块失败: \" .. tostring(ls)")
end
'
exit 0
EOF
chmod +x /etc/rc.local

步骤4:增加controller,注册页面路由

lua 复制代码
-- luci\lua\luci\controller\admin\log_switch.lua
module("luci.controller.admin.log_switch", package.seeall)

function index()
    entry({"admin", "system", "log_switch"}, cbi("admin/log_switch"), _("全局日志开关"), 90)
end

步骤5:增加view,基于cbi实现页面

lua 复制代码
-- luci\lua\luci\model\cbi\admin\log_switch.lua
local m, s, o
m = Map("luci_global_log", "LuCI全局日志开关", 
        "此设置控制所有LuCI应用(及使用nixio.syslog的Lua代码)的日志输出。")

s = m:section(TypedSection, "global", translate("全局开关"))
s.anonymous = true

o = s:option(Flag, "enable", translate("启用全局日志"), translate("取消勾选将静默丢弃几乎所有来自LuCI的syslog日志。"))
o.default = "1"
o.disabled = "0"
o.enabled = "1"
o.rmempty = false

o = s:option(ListValue, "log_level", translate("日志级别"), translate("设置日志级别。"))
o:value("info", " 信息 ")
o:value("debug", " 调试 ")
o:value("warning", " 警告 ")
o:value("err", " 错误 ")
o:value("crit", " 关键 ")
o.default = "info"
o.rmempty = false
-- o.widget = "radio" -- 如果不指定 widget,则默认为select

function m.on_after_save(self)
    -- 重新加载模块以清除可能的内存缓存
    package.loaded["luci.log_switch"] = nil
    local ls = require "luci.log_switch"
    if ls then
        -- 重新应用补丁,确保使用最新的配置
        ls.apply_patch()
    end
    -- 可选的日志记录
    local nixio = require "nixio"
    local cursor = require "luci.model.uci".cursor()
    local enabled = cursor:get("luci_global_log", "settings", "enable") or "1"
    -- 下面这个日志其实已经看不到了,因为日志被禁用了
    nixio.syslog("info", "[LogSwitch] 配置已保存并重新应用补丁,状态:" .. (enabled == "1" and "启用" or "禁用"))
end

return m

步骤6:在之前的文件列表下载功能中增加日志功能

lua 复制代码
-- luci\lua\luci\controller\myapp\custom_file_downloader.lua
module("luci.controller.myapp.custom_file_downloader", package.seeall)

-- 新增:一个安全的日志函数,始终检查全局开关
local function my_log(level, message)
    -- 每次记录都实时读取UCI配置
    local cursor = require "luci.model.uci".cursor()
    local enabled = cursor:get("luci_global_log", "settings", "enable") or "1"

    if enabled == "1" then
        local nixio = require "nixio"
        nixio.syslog(level, "[FileDownloader] " .. message)
    end
    -- 如果enabled为"0",则静默丢弃
end

function index()
    -- 在LuCI主菜单的"系统"下注册一个入口
    entry({"admin", "system", "file_download"}, firstchild(), _("文件下载"), 60).index = true

    -- 第一个子节点:显示文件列表页面
    entry({"admin", "system", "file_download", "list"}, template("custom_file_downloader/file_list"), _("文件列表"),
        1)

    -- 第二个子节点:处理文件下载的实际请求(这是一个调用函数,而非页面)
    entry({"admin", "system", "file_download", "download"}, call("download_file"))

    -- 新增:测试下载页面
    entry({"admin", "system", "file_download", "test"}, template("custom_file_downloader/test_download"),
        _("测试下载"), 3)

    -- 新增:处理/test.json文件的下载请求
    entry({"admin", "system", "file_download", "get_test_json"}, call("download_test_json"))
end

-- 替换旧的 get_file_list 函数
function get_file_list(directory)
    local fs = require "nixio.fs"
    local files = {}

    -- 使用 nixio.fs.dir 迭代目录
    for filename in fs.dir(directory) do
        if filename ~= "." and filename ~= ".." then
            local filepath = directory .. "/" .. filename
            local stat = fs.stat(filepath)
            if stat then
                table.insert(files, {
                    name = filename,
                    size = stat.size,
                    -- nixio.fs.stat 返回的 mtime 已经是时间戳
                    modtime = os.date("%Y-%m-%d %H:%M:%S", stat.mtime),
                    path = filepath
                })
            end
        end
    end
    table.sort(files, function(a, b)
        return a.name < b.name
    end)
    return files
end

-- 处理文件下载的Action函数
function download_file()
    my_log("info", "download_file 被调用")
    local fs = require "nixio.fs"
    local http = require "luci.http"
    local filepath = luci.http.formvalue("file") -- 从GET参数中获取文件路径

    my_log("info", "filepath: " .. filepath)

    -- **安全检查:确保文件路径在允许的范围内,防止目录遍历攻击**
    local allowed_dir = "/tmp" -- 只允许下载/tmp目录下的文件
    if not filepath or not filepath:find("^" .. allowed_dir) then
        http.status(403, "Forbidden")
        http.write("Access denied.")
        return
    end

    -- 检查文件是否存在且是普通文件
    if not fs.stat(filepath) or fs.stat(filepath).type ~= "reg" then
        http.status(404, "Not Found")
        http.write("File not found.")
        return
    end

    -- 获取文件名(去除路径)
    local filename = filepath:match("([^/]+)$")
    my_log("info", "filename: " .. filename)

    -- 设置HTTP响应头以触发下载
    http.header('Content-Disposition', 'attachment; filename="' .. filename .. '"')
    http.header('Content-Type', 'application/octet-stream')
    http.header('Content-Length', tostring(fs.stat(filepath).size))

    -- 以二进制块模式读取并发送文件内容
    local chunk_size = 4096 -- 或调整为 8192, 16384 以获得更好性能
    local fd = nixio.open(filepath, "r")
    if fd then
        local chunk = fd:read(chunk_size)
        while chunk do
            http.write(chunk)
            chunk = fd:read(chunk_size)
            my_log("info", "chunk:" .. chunk)
            if not chunk or #chunk == 0 then
                break
            end
        end
        -- 无论成功与否,都确保关闭文件描述符
        fd:close()

    end
    -- 简洁可靠的读取方式
    -- local fd = nixio.open(filepath, "r")

    -- if fd then
    --     -- 使用 pcall 捕获读取过程中可能发生的任何异常
    --     local ok, data_or_error = pcall(fd.readall, fd)
    --     nixio.syslog("info", "ok:" ..tostring(ok))
    --     nixio.syslog("info", "data:" ..data_or_error)

    --     -- 读取完成后立即关闭文件,释放资源
    --     fd:close()

    --     -- 根据读取结果处理  
    --     if ok and data_or_error then
    --         -- 成功读取到数据
    --         http.write(data_or_error)
    --         nixio.syslog("info", "data:" ..data_or_error)
    --     else
    --         -- 读取失败:ok为false时,data_or_error是错误信息;data_or_error为nil时是EOF。
    --         -- 可以选择记录日志或返回错误,但至少不会"卡住"
    --         -- 例如:http.status(500, "Read Error")
    --         nixio.syslog("info", "data:" .. data_or_error)
    --         http.write("读取文件时发生错误")
    --     end
    -- end
    -- 注意:这个函数不返回任何值,因为我们已经直接操作了HTTP响应流
    -- 使用nixio.fs.readfile 函数
    -- local data = nixio.fs.readfile(filepath)
    -- if data then
    --     http.write(data)
    --     nixio.syslog("info", "data:" .. data)
    -- else
    --     nixio.syslog("err", "读取文件失败: " .. filepath)
    --     http.status(500, "Read Error")
    --     http.write("读取文件时发生错误")
    -- end
end

-- 新增:专门下载 /tmp/.lastlog 文件 的函数
function download_test_json()
    local nixio = require "nixio"
    local fs = nixio.fs
    local http = require "luci.http"

    local filepath = "/tmp/.lastlog"

    -- 1. 更详细的文件检查
    local stat = fs.stat(filepath)
    if not stat then
        http.status(404, "Not Found")
        http.write("错误:文件不存在 - " .. filepath)
        return
    end
    if stat.type ~= "reg" then
        http.status(400, "Bad Request")
        http.write("错误:目标不是常规文件 - " .. filepath)
        return
    end

    -- 2. (可选) 增加文件大小检查,避免大文件耗尽内存
    local max_size_allowed = 1024 * 1024 * 10 -- 例如10MB
    if stat.size > max_size_allowed then
        http.status(413, "File Too Large")
        http.write("错误:文件超过大小限制 (" .. max_size_allowed .. " bytes)")
        return
    end

    -- 3. 设置HTTP响应头
    http.header('Content-Disposition', 'attachment; filename="lastlog"')
    http.header('Content-Type', 'application/json')
    http.header('Content-Length', tostring(stat.size))

    -- 4. 使用 readall() 读取并发送(你的核心修正)
    local fd = nixio.open(filepath, "r")
    if fd then
        -- 使用 pcall 安全地调用 readall,捕获可能的读取错误
        local ok, data = pcall(fd.readall, fd)
        fd:close() -- 确保文件描述符被关闭

        if ok and data then
            http.write(data)
        else
            http.status(500, "Internal Server Error")
            http.write("错误:读取文件失败")
        end
    else
        http.status(500, "Internal Server Error")
        http.write("错误:无法打开文件")
    end
end

步骤7:测试与验证

  1. 访问LuCI界面,进入"系统"->"日志"->"全局日志"。
  2. 切换开关状态并观察:通过logread -f命令实时查看。关闭日志后,所有Luci操作(如点击菜单)产生的user.info.lua:日志应大幅减少或消失。
  3. 测试应用:操作文件下载模块,验证日志是否随开关控制。

开启后,并操作文件下载模块,查看日志:

bash 复制代码
root@Eboy:~# logread -f
Tue Dec 30 03:33:49 2025 user.info lua: luci: accepted login on /admin/system/log_switch for root from 10.1.80.225
Tue Dec 30 03:33:52 2025 user.info lua: LuCI全局日志补丁已应用,日志功能已启用
Tue Dec 30 03:33:52 2025 user.info lua: original_syslog==nixio.syslog:false
Tue Dec 30 03:33:52 2025 user.info lua: [LogSwitch]:true
Tue Dec 30 03:33:52 2025 user.info lua: [LogSwitch] 配置已保存并重新应用补丁,状态:启用
Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] download_file 被调用
Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] filepath: /tmp/.lastlog
Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] filename: .lastlog
Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] chunk:.803577] 001: [XRADIO] Allocated hw_priv @ (ptrval) Mon Dec 29 17:13:32 2025 kern.err kernel: [   11.989943] 001: [XRADIO] Detect SDIO card 0 Mon Dec 29 17:13:32 2025 daemon.info dnsmasq[2611]: Connected to system UBus Mon Dec 29 17:13:32 2025 daemon.info dnsmasq[2611]: started, version 2.85 cachesize 10000 Mon Dec 29 17:13:32 2025 daemon.info dnsmasq[2611]: compile time options: IPv6 GNU-getopt no-DBus UBus no-i18n no-IDN DHCP no-DHCPv6 no-Lua TFTP no-conntrack no-ipset no-auth no-cryptohash no-DNSSEC no-ID loop-detect inotify dumpfile Mon Dec 29 17:13:32 2025 daemon.info dnsmasq[2611]: UBus support enabled: connected to system bus Mon Dec 29 17:13:32 2025 daemon.warn dnsmasq[2611]: warning: interface p2p-wlan0-0 does not currently exist Mon Dec 29 17:13:32 2025 daemon.warn dnsmasq[2611]: warning: interface wlan0 does not currently exist Mon Dec 29 17:13:32 2025 daemon.info dnsmasq-dhcp[2611]: DHCP, IP range 192.168.6.2 -- 192.168.6.255, lease time 1h Mon Dec
Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] chunk:s-gadget 4100000.udc-controller: failed to start g1: -19 Tue Dec 30 01:13:37 2025 daemon.err nmbd[2587]: [2025/12/30 01:13:37.641032,  0] ../../source3/lib/interface.c:662(load_interfaces) Tue Dec 30 01:13:37 2025 daemon.info avahi-daemon[2962]: Joining mDNS multicast group on interface lo.IPv4 with address 127.0.0.1. Tue Dec 30 01:13:37 2025 daemon.info avahi-daemon[2962]: New relevant interface lo.IPv4 for mDNS. Tue Dec 30 01:13:37 2025 daemon.info avahi-daemon[2962]: Registering new address record for 127.0.0.1 on lo.IPv4. Tue Dec 30 01:13:37 2025 daemon.info avahi-daemon[2962]: Joining mDNS multicast group on interface lo.IPv6 with address ::1. Tue Dec 30 01:13:37 2025 daemon.info avahi-daemon[2962]: New relevant interface lo.IPv6 for mDNS. Tue Dec 30 01:13:37 2025 daemon.info avahi-daemon[2962]: Registering new address record for ::1 on lo.*. Tue Dec 30 01:13:37 2025 daemon.notice netifd: Interface 'loopback' is enabled Tue Dec 30 01:13:37 2025 daemon.noti
Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] chunk:ne: Tue Dec 30 01:13:38 2025 daemon.notice procd: /etc/rc.d/S95done: amixer: Cannot find the given element from control hw:audiocodec Tue Dec 30 01:13:38 2025 daemon.notice procd: /etc/rc.d/S95done: Tue Dec 30 01:13:38 2025 daemon.notice procd: /etc/rc.d/S95done: amixer: Cannot find the given element from control hw:audiocodec Tue Dec 30 01:13:38 2025 daemon.notice procd: /etc/rc.d/S95done: Tue Dec 30 01:13:38 2025 daemon.notice procd: /etc/rc.d/S95done: amixer: Cannot find the given element from control hw:audiocodec Tue Dec 30 01:13:38 2025 daemon.notice procd: /etc/rc.d/S95done: Tue Dec 30 01:13:38 2025 daemon.notice procd: /etc/rc.d/S95done: amixer: Cannot find the given element from control hw:audiocodec Tue Dec 30 01:13:38 2025 daemon.notice procd: /etc/rc.d/S95done: Tue Dec 30 01:13:38 2025 daemon.notice procd: /etc/rc.d/S95done: amixer: Cannot find the given element from control hw:audiocodec Tue Dec 30 01:13:38 2025 daemon.notice procd: /etc/rc.d/S95do
Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] chunk:727]: [2025/12/30 01:13:43.577359,  0] ../../lib/util/become_daemon.c:136(daemon_ready) Tue Dec 30 01:13:43 2025 daemon.err nmbd[3727]:   daemon_ready: daemon 'nmbd' finished starting up and ready to serve connections Tue Dec 30 01:13:43 2025 daemon.err nmbd[3727]: [2025/12/30 01:13:43.581474,  0] ../../source3/nmbd/nmbd_namequery.c:109(query_name_response) Tue Dec 30 01:13:43 2025 daemon.err nmbd[3727]:   query_name_response: Multiple (2) responses received for a query on subnet 10.1.80.229 for name WORKGROUP<1d>. Tue Dec 30 01:13:43 2025 daemon.err nmbd[3727]:   This response was from IP 10.1.80.226, reporting an IP address of 10.1.80.226. Tue Dec 30 01:13:43 2025 daemon.notice procd: /etc/rc.d/S95done: sh: syntax error: unexpected "(" Tue Dec 30 01:13:43 2025 daemon.info procd: - init complete - Tue Dec 30 01:13:44 2025 daemon.err nmbd[3727]: [2025/12/30 01:13:44.009390,  0] ../../source3/nmbd/nmbd_mynames.c:36(my_name_register_failed) Tue Dec 30 01:13:44 20
Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] chunk:ile time options: IPv6 GNU-getopt no-DBus UBus no-i18n no-IDN DHCP no-DHCPv6 no-Lua TFTP no-conntrack no-ipset no-auth no-cryptohash no-DNSSEC no-ID loop-detect inotify dumpfile Mon Dec 29 17:13:32 2025 daemon.info dnsmasq[2611]: UBus support enabled: connected to system bus Mon Dec 29 17:13:32 2025 daemon.warn dnsmasq[2611]: warning: interface p2p-wlan0-0 does not currently exist Mon Dec 29 17:13:32 2025 daemon.warn dnsmasq[2611]: warning: interface wlan0 does not currently exist Mon Dec 29 17:13:32 2025 daemon.info dnsmasq-dhcp[2611]: DHCP, IP range 192.168.6.2 -- 192.168.6.255, lease time 1h Mon Dec Tue Dec 30 01:17:23 2025 user.info lua: [FileDownloader] chunk:s-gadget 4100000.udc-controller: failed to start g1: -19 Tue Dec 30 01:13:37 2025 daemon.err nmbd[2587]: [2025/12/30 01:13:37.641032,  0] ../../source3/lib/interface.c:662(load_interfaces) Tue Dec 30 01:13:37 2025 daemon.info avahi-daemon[2962]: Joining mDNS multicast group on interface lo.IPv4 with a
Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] chunk:n.warn dnsmasq[2611]: warning: interface p2p-wlan0-0 does not currently exist Mon Dec 29 17:13:32 2025 daemon.warn dnsmasq[2611]: warning: interface wlan0 does not currently exist Mon Dec 29 17:13:32 2025 daemon.info dnsmasq-dhcp[2611]: DHCP, IP range 192.168.6.2 -- 192.168.6.255, lease time 1h Mon Dec Tue Dec 30 01:17:23 2025 user.info lua: [FileDownloader] chunk:s-gadget 4100000.udc-controller: failed to start g1: -19 Tue Dec 30 01:13:37 2025 daemon.err nmbd[2587]: [2025/12/30 01:13:37.641032,  0] ../../source3/lib/interface.c:662(load_interfaces) Tue Dec 30 01:13:37 2025 daemon.info avahi-daemon[2962]: Joining mDNS multicast group on interface lo.IPv4 with a Tue Dec 30 01:17:23 2025 user.info lua: [FileDownloader] chunk:Tue Dec 30 01:17:23 2025 user.info lua: [FileDownloader] chunk:727]: [2025/12/30 01:13:43.577359,  0] ../../lib/util/become_daemon.c:136(daemon_ready) Tue Dec 30 01:13:43 2025 daemon.err nmbd[3727]:   daemon_ready: daemon 'nmbd' finished star
Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] chunk:lua: luci: accepted login on /admin/system/log_switch for root from 10.1.80.225 Tue Dec 30 03:33:52 2025 user.info lua: LuCI全局日志补丁已应用,日志功能已启用 Tue Dec 30 03:33:52 2025 user.info lua: original_syslog==nixio.syslog:false Tue Dec 30 03:33:52 2025 user.info lua: [LogSwitch]:true Tue Dec 30 03:33:52 2025 user.info lua: [LogSwitch] 配置已保存并重新应用补丁,状态:启用 Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] download_file 被调用 Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] filepath: /tmp/.lastlog Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] filename: .lastlog Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] chunk:.803577] 001: [XRADIO] Allocated hw_priv @ (ptrval) Mon Dec 29 17:13:32 2025 kern.err kernel: [   11.989943] 001: [XRADIO] Detect SDIO card 0 Mon Dec 29 17:13:32 2025 daemon.info dnsmasq[2611]: Connected to system UBus Mon Dec 29 17:13:32 2025 daemon.info dnsm
Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] chunk: [2025/12/30 01:13:43.581474,  0] ../../source3/nmbd/nmbd_namequery.c:109(query_name_response) Tue Dec 30 01:13:43 2025 daemon.err nmbd[3727]:   query_name_response: Multiple (2) responses received for a query on subnet 10.1.80.229 for name WORKGROUP<1d>. Tue Dec 30 01:13:43 2025 daemon.err nmbd[3727]:   This response was from IP 10.1.80.226, reporting an IP address of 10.1.80.226. Tue Dec 30 01:13:43 2025 daemon.notice procd: /etc/rc.d/S95done: sh: syntax error: unexpected "(" Tue Dec 30 01:13:43 2025 daemon.info procd: - init complete - Tue Dec 30 01:13:44 2025 daemon.err nmbd[3727]: [2025/12/30 01:13:44.009390,  0] ../../source3/nmbd/nmbd_mynames.c:36(my_name_register_failed) Tue Dec 30 01:13:44 20 Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] chunk:ile time options: IPv6 GNU-getopt no-DBus UBus no-i18n no-IDN DHCP no-DHCPv6 no-Lua TFTP no-conntrack no-ipset no-auth no-cryptohash no-DNSSEC no-ID loop-detect inotify dumpfile Mon Dec 29 17:13:32 202
Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] chunk:Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] chunk:lua: luci: accepted login on /admin/system/log_switch for root from 10.1.80.225 Tue Dec 30 03:33:52 2025 user.info lua: LuCI全局日志补丁已应用,日志功能已启用 Tue Dec 30 03:33:52 2025 user.info lua: original_syslog==nixio.syslog:false Tue Dec 30 03:33:52 2025 user.info lua: [LogSwitch]:true Tue Dec 30 03:33:52 2025 user.info lua: [LogSwitch] 配置已保存并重新应用补丁,状态:启用 Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] download_file 被调用 Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] filepath: /tmp/.lastlog Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] filename: .lastlog Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] chunk:.803577] 001: [XRADIO] Allocated hw_priv @ (ptrval) Mon Dec 29 17:13:32 2025 kern.err kernel: [   11.989943] 001: [XRADIO] Detect SDIO card 0 Mon Dec 29 17:13:32 2025 daemon.info dnsmasq[2611]: Con
Tue Dec 30 03:34:18 2025 user.info lua: [FileDownloader] chunk:

关闭后,操作文件下载模块,查看日志:

bash 复制代码
Tue Dec 30 03:35:27 2025 user.info lua: LuCI全局日志补丁已应用,日志功能已禁用
Tue Dec 30 03:35:27 2025 user.info lua: original_syslog==nixio.syslog:false
Tue Dec 30 03:35:27 2025 user.info lua: [LogSwitch]:false

可见用户应用日志已消失。

相关推荐
小李云雾1 天前
FastAPI 后端开发:文件上传 + 表单提交
开发语言·python·lua·postman·fastapi
曼巴UE51 天前
Unlua 官方案例
c++·ue5·lua·ue
列星随旋2 天前
基于 Redis + Lua,实现“多维度原子限流”(令牌桶 + 滑动窗口)
java·redis·lua
上海合宙LuatOS2 天前
LuatOS扩展库API——【exgnss】GNSS定位
物联网·lua·luatos
0xDevNull2 天前
Redis Lua 脚本详细教程
redis·缓存·lua
上海合宙LuatOS2 天前
LuatOS扩展库API——【exlcd】显示屏控制
物联网·lua·luatos
0xDevNull2 天前
Spring Boot 中使用 Redis Lua 脚本详细教程
spring boot·redis·lua
DJ斯特拉4 天前
Redis使用lua脚本
junit·单元测试·lua
Aktx20FNz4 天前
OpenClaw中级到高级教程
lua
LcGero4 天前
Lua + Cocos Creator 实战:用 Lua 驱动 UI 与游戏逻辑
游戏·ui·lua