]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
table_print: also print function addresses
authorPetr Špaček <petr.spacek@nic.cz>
Tue, 16 Apr 2019 06:29:17 +0000 (08:29 +0200)
committerPetr Špaček <petr.spacek@nic.cz>
Tue, 16 Apr 2019 06:29:17 +0000 (08:29 +0200)
It gets handy for debugging, especially when looking at dufferent
callback "instances".

daemon/lua/sandbox.lua.in

index 4380d50a6f8341789ad88b532cbee976a6b49ab8..b2b26c4312b755438b9ffc72c0645472bbe996ce 100644 (file)
@@ -442,8 +442,9 @@ function table_print (tt, indent, done)
                                result = result .. string.rep (" ", indent)
                                result = result .. "}\n"
                        elseif type (value) == "function" then
-                               result = result .. string.format("[%s] => function %s%s\n",
-                                        tostring(key), tostring(key), funcsign(value))
+                               result = result .. string.format("[%s] => function %s%s: %s\n",
+                                        tostring(key), tostring(key), funcsign(value),
+                                        string.sub(tostring(value), 11))
                        else
                                result = result .. string.format("[%s] => %s\n",
                                         tostring (key), printable(value))
@@ -452,7 +453,8 @@ function table_print (tt, indent, done)
        else  -- not a table
                local tt_str
                if type(tt) == "function" then
-                       tt_str = string.format("function%s\n", funcsign(tt))
+                       tt_str = string.format("function%s: %s\n", funcsign(tt),
+                                               string.sub(tostring(tt), 11))
                else
                        tt_str = tostring(tt)
                end