prosody: Modified function metatable for better string representation of functions.

Fri, 07 May 2010 16:02:29 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Fri, 07 May 2010 16:02:29 +0500
changeset 3024
9c74785c6351
parent 3023
454e1cf18daf
child 3025
f1e1b7629807

prosody: Modified function metatable for better string representation of functions.

prosody file | annotate | diff | comparison | revisions
--- a/prosody	Fri May 07 16:00:33 2010 +0500
+++ b/prosody	Fri May 07 16:02:29 2010 +0500
@@ -143,6 +143,10 @@
 			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
 

mercurial