Does Luci have print function?

1.8k Views Asked by At

I want to print my parsing value at Luci. Here is my code.

local val = {}
mm = Map("test", translate("For TEST"))
test=mm:section(TypedSection, "test", translate("TEST"))
test.anonymous = true
test.addremove = false

rssis = test:option(DummyValue, "rssi", translate("RSSI"))
t = test:option(DummyValue, "tx", translate("TX"))
r = test:option(DummyValue, "rx", translate("RX"))
local f = io.popen("iwpriv wlan0 stat")

for line in f:lines() do
    for s in line:gmatch("(%S+)%s") do
            table.insert(val, s)
    end

    for i, v in ipairs(val) do

    end
end
f:close()

rssis:value(val[35])

if val[41] == "6M" then
    t:value(val[41], translate("Disconnect"))
else
    t:value(33, translate("Good"))
end

if val[49] == "6M" then
    r:value(val[49], translate("DIsconnect"))
else
    r:value(33, translate("GOOD"))
end
return mm

I saw the DummyValue which Creates a readonly field in the form. So I used it instead of print function. However it has errors "attempt to index global 'rssis' (a nil value)"

Only in lua file(not used for Luci) If i used the print function, it has no error. Does Luci has print function?

1

There are 1 best solutions below

1
On

There is a luci.util.perror("blah blah") function that prints to the syslog. you can then use the shell command "logread" to display in a console.

I guess this is what you need to debug your code.