diff options
author | Kim Alvefur <zash@zash.se> | 2020-10-09 17:41:10 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2020-10-09 17:41:10 +0200 |
commit | c5933e9ed7902f748e561d92b741d09468ba8067 (patch) | |
tree | 3f5226b3a82fa1588064f1ebb990df3bcf00dea6 /util/startup.lua | |
parent | 9302a14d803625e06d7a93a9b7d498a1219c383d (diff) | |
download | prosody-c5933e9ed7902f748e561d92b741d09468ba8067.tar.gz prosody-c5933e9ed7902f748e561d92b741d09468ba8067.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.lua | 10 |
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 |