prosody: Modified function metatable for better string representation of functions.
authorWaqas Hussain <waqas20@gmail.com>
Fri, 7 May 2010 11:02:29 +0000 (16:02 +0500)
committerWaqas Hussain <waqas20@gmail.com>
Fri, 7 May 2010 11:02:29 +0000 (16:02 +0500)
prosody

diff --git a/prosody b/prosody
index 0232b83b704a81ef90992c0e551835135d985de4..e4e821050d60829c9b8c652d33e003ec7bde470c 100755 (executable)
--- a/prosody
+++ b/prosody
@@ -143,6 +143,10 @@ function set_function_metatable()
                        debug.setupvalue(f, i, value);
                end
        end
+       function mt.__tostring(f)
+               local info = debug.getinfo(f);
+               return ("function(%s:%d)"):format(info.short_src:match("[^\\/]*$"), info.linedefined);
+       end
        debug.setmetatable(function() end, mt);
 end