Debugging values

Is there a generic to_string type of method that will print out an objects values? For instance I would like to see what the request.query value is on the agent. If I write to the log, I get the table id.

Actually, the foreach seems to work Ok, but a generic to_yml, or inspect method would be useful if there is one?

Here’s a function that will do what you’re looking for
`function tokenize(t, i = 0) {
local indentString = “”;
for(local x = 0; x < i; x++) indentString += “.”;

if (typeof(t) != "table" && typeof(t) != "array") {
    server.log(indentString + t)
} else {
    foreach(k, v in t) {
        if (typeof(v) == "table" || typeof(v) == "array") {
            local par = "[]";
            if (typeof(v) == "table") par = "{}";
            
            server.log(indentString + k + ": " + par[0].tochar());
            tokenize(v, i+4);
            server.log(par[1].tochar());
        } 
        else { 
            server.log(indentString + k + ": " + v);
        }
    }
}

}

tokenize(1);
tokenize(“hello world”);
tokenize({
a = [“a”, “b”, “c”],
b = {
“b1”: “This”,
“b2”: “Is”,
“b3”: “A”,
“b4”: “Test”
},
c = 5
});
function test() {
return;
}
tokenize(test);`

And here’s the output:

2013-12-02 11:16:25 UTC-8: [Agent] 1 2013-12-02 11:16:25 UTC-8: [Agent] hello world 2013-12-02 11:16:25 UTC-8: [Agent] a: [ 2013-12-02 11:16:25 UTC-8: [Agent] ....0: a 2013-12-02 11:16:25 UTC-8: [Agent] ....1: b 2013-12-02 11:16:25 UTC-8: [Agent] ....2: c 2013-12-02 11:16:25 UTC-8: [Agent] ] 2013-12-02 11:16:25 UTC-8: [Agent] c: 5 2013-12-02 11:16:25 UTC-8: [Agent] b: { 2013-12-02 11:16:25 UTC-8: [Agent] ....b1: This 2013-12-02 11:16:25 UTC-8: [Agent] ....b2: Is 2013-12-02 11:16:25 UTC-8: [Agent] ....b3: A 2013-12-02 11:16:25 UTC-8: [Agent] ....b4: Test 2013-12-02 11:16:25 UTC-8: [Agent] } 2013-12-02 11:16:25 UTC-8: [Agent] (function : 0x7fe7f8f3e100)

Perfect! Thank you.