% local fs = require "nixio.fs" local sys = require "luci.sys" -- 全部在一个 Lua 块里拼好 HTML,最后一次性输出。 -- 实测踩坑:本机 luci 模板解析器是 C 写的(parser.so), -- 对「多个 <% %> 块 + 含百分号/尖号的 HTML 混排」会误判配对, -- 报 '%>' expected before end of file。单块写法最稳。 local function esc(s) return pcdata(s or "") end local mine = fs.readfile("/var/log/cloudreve.log") or "" -- Cloudreve 自己的输出走 procd -> syslog,只能从 logread 拿 local raw = sys.exec("logread") or "" local buf = {} for line in raw:gmatch("[^\r\n]+") do if line:lower():find("cloudreve", 1, true) then buf[#buf + 1] = line end end local total = #buf local start = total - 119 if start < 1 then start = 1 end local sysout = {} for i = start, total do sysout[#sysout + 1] = buf[i] end sysout = table.concat(sysout, "\n") local h = {} local function add(x) h[#h + 1] = x end add('
') -%> <%=table.concat(h, "\n")%>