Hi other ionized people,

Could someone please give me some little hints how to debug a lua
script.

(And sorry for the long mail - i wanted to give all infos)

I have some experience with python, so when i don't get the result
i expect, i use a "print" to see what's wrong.

My problem is that the statusd_load doesn't show me the coloured
hints when the specific values are reached. I can't find a solution
because it seems nobody else has this problem :(



The statusd_maildir works !
It changes the colours depending from the number of new messages in
my mailbox.


For notice: I have the lua locale problem, but
i found out, that this is probably not the real
cause for my problem.

When i explicitly activate the meter settings for load
in cfg_statusbar.lua, i get messages like this:
malformed number near 2.3`

My locale settings:
LANG=de_DE.utf8
LC_CTYPE="de_DE.utf8"
LC_NUMERIC="de_DE.utf8"
LC_TIME="de_DE.utf8"
LC_COLLATE="de_DE.utf8"
LC_MONETARY="de_DE.utf8"
LC_MESSAGES="de_DE.utf8"
LC_PAPER="de_DE.utf8"
LC_NAME="de_DE.utf8"
LC_ADDRESS="de_DE.utf8"
LC_TELEPHONE="de_DE.utf8"
LC_MEASUREMENT="de_DE.utf8"
LC_IDENTIFICATION="de_DE.utf8"
LC_ALL=de_DE.utf8


Deactivating own settings gives me default builtin settings
of the load statusd monitor and no error messages. Setting
the important_treshold (critical...) to an integer value also results
in getting no error messages but nothing more.


What i also tried:
1.) Setting the LC_NUMERIC=C helped that i don't get the "malformed ..."
message but no success with coloured load values in statusbar.

2.) Executing mod_statusbar.inform("load_hint", "critical")  "normal", or
"important" works !


So what i ask you for:

Please could someone tell me in short how to debug a lua script.
I am no lua coder, neither a beginning. I only want to get rid
of the problem. Perhaps this knowledge can help me in the future.

In order to find the problem, i changed the value of the parameter
from l to a defined integer value (as i expected floats would make be
the troublemakers), but floating point values also gives the result,
that the load_hints works !

Here is the place in statusd_load.lua:

--- 

local function get_hint(l)
    local v=tonumber(l)         <-- setting l to 3 or 3.2 works!
    local i="normal"
    if v then
        if v>settings.critical_threshold then
            i="critical"
        elseif v>settings.important_threshold then
            i="important"
        end
    end
    return i
end

---

I think something goes wrong in get_load_proc() (at least on my
system), but i can't check it out without to know how to see what 
that functions gives back.

How can i print out the return values of functions to the console
where i did my startx ?

I tried print(l) or io.write(l) within the functions but that gives me 
only syntax errors. Could it be that i have to import external functions 
with require ? I expected a print function would be builtin in a scripting
language.

Perhaps some of you could give me a good link for lua newbies so that
i can help myself. All i found myself was (from my point of view) not
so good for beginners.

Thanks in advance for any help,
Heiko

Reply via email to