aboutsummaryrefslogtreecommitdiffstats
path: root/util/startup.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-10-09 17:41:10 +0200
committerKim Alvefur <zash@zash.se>2020-10-09 17:41:10 +0200
commitf7b985822930ca7b6e8605173ac92ae80b28436a (patch)
tree3f5226b3a82fa1588064f1ebb990df3bcf00dea6 /util/startup.lua
parent9a137bf062a1141e22668634c16a627afc77dc50 (diff)
downloadprosody-f7b985822930ca7b6e8605173ac92ae80b28436a.tar.gz
prosody-f7b985822930ca7b6e8605173ac92ae80b28436a.zip
util.startup: Include arguments in function string representation
Improves usability of the console when digging around the internals. No specific rationale for the function<file:line>(args) format, it looked best of the variants I tried.
Diffstat (limited to 'util/startup.lua')
-rw-r--r--util/startup.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/util/startup.lua b/util/startup.lua
index af126e8c..358c491f 100644
--- a/util/startup.lua
+++ b/util/startup.lua
@@ -197,8 +197,14 @@ function startup.set_function_metatable()
end
end
function mt.__tostring(f)
- local info = debug.getinfo(f, "S");
- return ("function(%s:%d)"):format(info.short_src:match("[^\\/]*$"), info.linedefined);
+ local info = debug.getinfo(f, "Su");
+ for i = 1, info.nparams do
+ info[i] = debug.getlocal(f, i);
+ end
+ if info.isvararg then
+ info[info.nparams+1] = "...";
+ end
+ return ("function<%s:%d>(%s)"):format(info.short_src:match("[^\\/]*$"), info.linedefined, table.concat(info, ", "));
end
debug.setmetatable(function() end, mt);
end